-2

I am trying to match a string containing nothing before a character.

Consider the following lines:

'this is a valid line
  'this is also a valid line
 Any string ' this is an invalid line

I Need a regular expression that matches the first two line and does not match third line.

Basic regex tried was '.* but it matches all the three lines:

So need a regex that does not match a non empty string before '

poke
  • 369,085
  • 72
  • 557
  • 602
Jaskaran
  • 320
  • 5
  • 19

1 Answers1

2

perhaps try anchor at the beginning... ^\s*'.*

Billy Moon
  • 57,113
  • 24
  • 136
  • 237