-1

I am really not good with regular expressions and I come here for some assistance :). I am trying to combine regular expressions with something like AND. For example if we have a text file with:

abc1-xyz

abc1-ertxyz

abc1xyz

postxyz

abc1

I would like to match everything that starts with "abc1" AND also contains the letters "xyz" somewhere.

I know that I can start with:

/^abc1/

but I am not sure how to combine so it can also match to contain "xyz".

Thank you for your assistance in advance.

Biffen
  • 6,249
  • 6
  • 28
  • 36
kereza
  • 29
  • 3

1 Answers1

0

You should tell us with which language you are coding, regex engines are not always the same.

There is another ambiguous point : Do you need your string to CONTAIN xyz or to END WITH?

Considering you are coding on Javascript..

If you want it to contain xyz, try :

/^abc1.*xyz/

If you want it to end with xyz, try :

/^abc1.*xyz$/
Charly
  • 282
  • 1
  • 12