Hey All,
I am trying to extract some specified text from below Paragraph.
Any suggestions will be helpful.
Thanks in advance.
Input
SQL>
COUNT
0000
SQL> SQL>
DB SUM(AMOUNT)
D 0000000.00
C 0000000.00
Card-TechOps-Debit BOS-T1
Desired Ouput
Value of COUNT = 0000
Value of D = 0000000.00
Value of C = 0000000.00
Gokul001
(Gokul Balaji)
November 8, 2022, 6:30am
2
HI @prerna.gupta
You can try with this expression
System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=COUNT\n)\d+|(?<=^D\s|^C\s)\d.+")(0)
Output -> 0000
System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=COUNT\n)\d+|(?<=^D\s|^C\s)\d.+")(1)
Output -> 0000000.00
System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=COUNT\n)\d+|(?<=^D\s|^C\s)\d.+")(2)
Output -> 0000000.00
Regards
Gokul
1 Like
Gokul001
(Gokul Balaji)
November 8, 2022, 6:36am
3
You can also try with this expression @prerna.gupta
System.Text.RegularExpressions.Regex.Matches(YourString,"(?<=COUNT\n)\d+|(?<=^D\s|^C\s)\d.+",System.Text.RegularExpressions.RegexOptions.Multiline)
Regards
Gokul
Thanks much.
Just wanted to recheck the variable type for Input String ?
Gokul001
(Gokul Balaji)
November 8, 2022, 6:38am
5
This the input variable check out the screenshot @prerna.gupta
In the above screenshot what is data type for YourString ?
Gokul001
(Gokul Balaji)
November 8, 2022, 6:43am
7
Its as String variable type @prerna.gupta
If data type is string then facing error. Pls refer screenshot
Gokul001
(Gokul Balaji)
November 8, 2022, 6:54am
9
HI @prerna.gupta
Update the expression
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=COUNT\n)\d.+").Tostring
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=D\s)\d.+").Tostring
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=C\s)\d.+").Tostring
Check out the XAML file
RegexMulitple.xaml (5.5 KB)
Regards
Gokul
HI @prerna.gupta
Checkout this expression for the count
System.text.RegularExpressions.Regex.Match(StrVariable,"(?<=COUNT\n)\d+").ToString
For values of D and C if those D and C are dynamic try the below
String variable ValueofRows =
System.text.RegularExpressions.Regex.Match(StrVariable,"(?s)(?<=AMOUNT\)\n{2}).*(.*?)^\n").ToString
The above will get you those complete rows and will get all the number of rows for eg.
To get all the values
System.text.RegularExpressions.Regex.Matches(ValueofRows,"\d+")
if you loop on with the expression above in for each you will get the each and every match so that you can assign them to the datatable or whatever you want.
Hope this Helps
Regards
Sudharsan
Use .ToString at end of the expression @prerna.gupta
With updated expressions also facing same error as above.
I checked the xml file code as well, Can you try to save to output of message box in some variable pls ?
That is what is creating a problem.
Gokul001
(Gokul Balaji)
November 8, 2022, 7:00am
13
Can you tell us the variable type of your input? @prerna.gupta
Check this after giving .tostring in the value field of assign @prerna.gupta
Gokul001
(Gokul Balaji)
November 8, 2022, 7:02am
16
Try like this @prerna.gupta
System.Text.RegularExpressions.Regex.Match(YourString.Tostring,"(?<=COUNT\n)\d.+").Tostring
Check out this screenshot
Hi @prerna.gupta you can also use this regex
System.Text.RegularExpressions.Regex.Match(“yourString”,“((?<=COUNT\n).\d)|((?<=D\s?). \d)|((?<=C\s?).*\d)”)
With this expression Output is Null
@Tapan_Behera1 ,
With the above expression also its variable type mismatch error.
Can you suggest the datatype in which i can save the output of Regex ?
Gokul001
(Gokul Balaji)
November 8, 2022, 7:27am
20
Gokul001:
Update the expression
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=COUNT\n)\d.+").Tostring
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=D\s)\d.+").Tostring
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=C\s)\d.+").Tostring
Have you tried with this expression ? @prerna.gupta
Can you share the exact input here?