You are viewing limited content. For full access, please sign in.

Question

Question

regex for variations

asked on October 31, 2019 Show version history

Hi there,

I have an issue with regex...

The string could have the following variants:

My name is abc = My name

My-name is abc = My-name

my n.a. is abc = my n.a.

my   = my

 

I want that out of all these possible things the result should be after the = in BOLD

Thanks a million!

S

0 0

Replies

replied on October 31, 2019

([A-Za-z\.]*[\s\-]*[A-Za-z\.]*)

1 0
replied on October 31, 2019

Thanks, i just had to put numbers in: ([A-Za-z-0-9\.]*[\s\-]*[A-Za-z\.]*)

0 0
replied on October 31, 2019 Show version history

Hello,

I'm confused what the goal is based on your current examples.

Are those actual example strings? (e.g., "My name is Brianna") and you are trying to capture the part "My name" but not "is Brianna"?

Based on the examples, here are a few things it looks like you might be doing:

  • Capturing the first two words, where a hyphen might separate the first two words
  • Capturing anything before "is examplename", including if that part is omitted, like "My full name is abc" -> "My full name"
  • Capturing anything that's a variant on "my name", including if the name part is missing or shortened. If the input was "abc-is my name" would you want "abc-is" or "my name" as the result?

Are any of those correct?

You are not allowed to follow up in this post.

Sign in to reply to this post.