Please help with regex code to extract the text before a keyword and include the keyword in the output.
Sample input string:
This is a test.ca ABC123
Fixed keyword: “.ca”
Expected output: test.ca
I tried this: \b.*(?<=).ca
But it’s extracting everything from the start of the line until the keyword.
I recommend to get familiar with this website https://regexr.com/
Can you try the following pattern?
How about this pattern?
Thanks for the suggestion. The period before “ca” is important to differentiate the keyword from other strings that could contain “ca”. This code doesnt work when I tried \S*\W.ca
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.