I need a regex to check if a string followed this format: Client: [LastName, FirstName]_Doc
Basically the LastName, FirstName varies. I want to check if this format was followed while ignoring case.
Client: Doe,John_Doc //true
client: Doe, john_doc //true
CLIENT: Doe, john //false
Thanks in advance
Welcome back to the forums.
Does this Regex Pattern work for you? Was it just the pattern you needed?
Thanks mate, @Steven_McKeering :). This pattern works
Im just thinking of other scenarios and just wondering how can I add it to your pattern.
client:doe,john _Doc //true
Basically it’s possible that there’s no space between client: and last name and there could be a space between firstname and underscore.
Try this pattern
I have added two more “\s*” which will looks for either 0 or many spaces essentially.
Thanks for the Sample, expected Output and pattern. More info on the pattern is better.
Check out my Regex Megapost also
This also works for me.
Will definitely check out your post. Looks detailed and comprehensive.
Thanks again mate.
Hi bro @Steven_McKeering
Sorry forgot to mention that it’s possible that Last Name and First Name could be double names and could be short names, please see sample below:
Client:Dow Jones,Billy ray_doc //True
client: Dow Jones, B.R. _DOC //True
Appreciate your help as always. Thanks!
I got your back (why I already added the “-”). Names are tricky.
Try this updated pattern:
I have a second option but I am not sure if this suits your needs but this is a simplified version where First and Last name are not captured separately.
Extra unknown characters can be inserted into the square brackets “[ ]”. I would use a “\” to escape them just incase.
Thanks @Steven_McKeering. Both version works perfectly. Thanks for the tip
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.