Regex to extract text before keyword and include the keyword


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 ABC123

Fixed keyword: “.ca”

Expected output:

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


Can you try the following pattern?




1 Like

HI @6027ae06be5a67a04d29acc18

How about this pattern?



1 Like

Thank you, this works!

1 Like

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*\

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.