Hi all
I want to check if certain text is between two lines, e.g. - If “Receipt” is between “Photo of iPad” and “Test”
Any help would be greatly appreciated
Thanks
Hi all
I want to check if certain text is between two lines, e.g. - If “Receipt” is between “Photo of iPad” and “Test”
Any help would be greatly appreciated
Thanks
Try this
strText = strText .Replace(Environment.NewLine,string.Empty)
bool Contains = Regex.Match(strText,“(?<=Photo of iPad)(.*?)(?=Test)”).Value.Contains(“Receipt”)
Hi @vvaidya
Apologies for being a bit slow but I couldn’t work out if you meant do a match or an If (the condition throw me, and I didn’t think it would fit in an Assign) but neither work:
If error
Where am I going wrong?
Thanks!
You don’t need matches in this case, just if condition. In your if condition remove quotes and you should be good.
If (Regex.Match(strQuote,“(?<=Photo of iPad)(.*?)(?=Test)”).Value.Contains(“Receipt”))
Thanks,
Vinay
Hi Vinay
That makes more sense, thanks.
Now I’m getting this error:
Saying that Regex is not declared. Is there something else I need to do for this?
Thanks!
Hey @Short
You have to import “System.Text.RegularExpression” namespace in your project then you will be able to use Regex.
or can use as well like System.Text.RegularExpression.Regex but better to use import namespace approach.
Regards…!!
AKsh
Amazing, thank you!