Help with a Regex Pattern

Hello guys,
Thanks for helping again. please i have string that could come in several forms
1.) “TTN000216556880035450088|TRF”
2) “TTN000216556880035450088|TRF FROM MACK”
3) “TTN000216556880035450088”
4) “Transfer from josh TTN000216556880035450088 to jack”
5) “TTN000216556880035450088 0098123 TRANSFER 789121”
I need a regex pattern that could get the string that starts with TTN
which is “TTN000216556880035450088” . This string is the reference and it is what i need . it can be found in any position in a sentence and sometimes the reference might not be separated from the other words by a space , sometimes a special character can be used as a separator. i…e in 2) “TTN000216556880035450088|TRF FROM MACK”

Hi David,

It should start with TTN, That clear, Kindly mention something like Ends with or Number of character it should have.

So that we can frame a RegEx Pattern for it.

Warm Regards,
Ranjith Udayakumar

1 Like

@David_Oku

Please try this pattern "\bTTN.+?\b"

2 Likes

Hi @David_Oku

Below is the regex for the same
image


regexr.com/5804g

Mark this as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Thanks a lot guys, i must say i am really grateful @msan your pattern matches my requirement more its been very helpful.
Thanks too @Pratik_Wavhal i really appreciate , i really want to learn this regex , its so great. you were helpful too…

Thanks guys

1 Like

Hello @msan Thank you , please how do i write this for references starting with TTN, VNM, PSM, or SL all together. I am trying to say match if the reference starts with VNM, PSM, or SL

Use a group with a pipe like that:

"\b(TTN|VNM|PSM|SL).+?\b"

2 Likes

Thanks a lot… really grateful

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