I’m integrating with WhatsApp and need to parse a text message for a specific string. I’m looking for a text string that starts with the letters PRJ, however, this could be in various formats. For example it could come through as “PRJ123456” or “PRJ-1234” (the numbers are not always the same length).
Also, the text could come through as just the PRJ code, or it could come through inside of a paragraph of text (ie “Please use PRJ123456” or “Please use PRJ123456 to map to”)
Is the best way to accomplish this doing some sort of REGEX? If so, how would you write that to accommodate the different PRJ formats as well as the different lengths. I would imagine they would be surrounded by spaces if they’re in a paragraph, or its a standalone code.
Please ask chat gpt to get the Regex.
And use () to capture the required part.
Ahh, I don’t always think to jump to ChatGPT, but it did come to the rescue. Thanks!
The result was:
I did two parentheses in order to split the different segments as well as include the possibility of having a dash between the letters and number.
I just wanted to quickly jump in and say thank you for getting back to us and sharing the Regex that ChatGPT helped you with!
It’s awesome to see how AI technology is pushing the boundaries and making the future feel real. Thanks for keeping us informed and great work solving this!
@esowers I am glad to hear you made it.
ChatGPT can be super handy indeed!
But I totally feel you @esowers. I like to do things “on my own” too sometimes, or at least understand them better. So I just wanted to share a great resource to start learning RegEx, if you’re interested. Try regexone.com! And you can also use regex101.com to play around with them and test the RegExes before copying them to Make.
Just make sure to use the ECMAscript flavor in regex101 to ensure it works the same
Thanks a lot for stepping in here and sharing this helpful resource!
This is super valuable stuff and I’m sure it will come in handy to many folks who - just like you - wanna dive deep into things and learn them on their own