Regex for a string that begins but does not end with the "

Is it possible to write a regular expression that represents lines starting with "and do not end with " ?

+5
source share
3 answers

You can use regex:

^".*[^"]$

Explanation:

^     Start of line anchor
"     A literal "
.*    Any junk
[^"]  Any non " character
$     End of line anchor
+7
source

There you go:

^".*[^"]$

^" starts with "
.* some chars (or none)
[^"]$ doesn't end with "
+2
source

Here you go

^".*[^"]$

What regular expression engine are you using?

+2
source

All Articles