I have to collect data after the word ‘summary’ and up to the second ‘Balance at xxxxx’
The line after ‘Balance at’ is not always the same.
example:
Summary:
Balance at xxxxxx
xxxxxx xxxx
xxxxx
xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
Balance at xxxxxxxxxxxx
shdgjwhednsbdkj
I found the index of the Second ‘Balance at’ but I am not sure how to identify it till the line break.
Yoichi
(Yoichi)
November 28, 2022, 2:30pm
2
Hi,
How about the following expression?
System.Text.RegularExpressions.Regex.Match(yourString,"Summary:[\s\S]*?Balance at[\s\S]*?Balance at.*").Value
Regards,
Anil_G
(Anil Gorthi)
November 28, 2022, 2:42pm
3
sunilkanth:
same
Hi @sunilkanth
so basically you can give the start and the count from where you want the identification to start from so I passed the Index of Balance at and search for new line after that line
str.IndexOf(Environment.newLine,str.IndexOf(“Balance at”,str.IndexOf(“Balance at”) + 1))
You can try like this
Here I passed the start of Balance at to find second balance at and then pass that index to start searching from second balance at to find the New line feed
cheers
I am getting the following error
The image is not a screenshot its mobile image hence the poor quality.
Yoichi
(Yoichi)
November 28, 2022, 3:22pm
5
Hi,
For now can you try to remove the following red arrow pointed double quote?
Regards,
Anil_G
(Anil Gorthi)
November 28, 2022, 4:06pm
7
Hi @sunilkanth
Try this
str.IndexOf(Environment.newLine,str.IndexOf(“Balance at”,str.IndexOf(“Balance at”) + 1))
If the new line character is different then use \n or vbcrlf or \r\n in place of environment.Newline
cheers
Yoichi
(Yoichi)
November 28, 2022, 4:09pm
8
Hi,
Can you share your input text?
Regards
I tweaked your answer and it worked.
I added \s between Balance and at and \n at the end.
Thanks for the help
1 Like
(yourstring,“Summary:[\s\S]?Balance\sat[\s\S] ?Balance\sat.*\n”)
1 Like