Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for string that starts but doesn't end with "

Tags:

regex

Is there an option to write a regex that represents strings that start with " and don't end with " ?

like image 396
cookya Avatar asked Jun 01 '12 11:06

cookya


People also ask

What does '$' mean in regex?

$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.

What is difference [] and () in regex?

[] denotes a character class. () denotes a capturing group. [a-z0-9] -- One character that is in the range of a-z OR 0-9. (a-z0-9) -- Explicit capture of a-z0-9 .

What does regex 0 * 1 * 0 * 1 * Mean?

Basically (0+1)* mathes any sequence of ones and zeroes. So, in your example (0+1)*1(0+1)* should match any sequence that has 1. It would not match 000 , but it would match 010 , 1 , 111 etc. (0+1) means 0 OR 1. 1* means any number of ones.

What is the difference between \b and \b in regular expression?

Using regex \B-\B matches - between the word color - coded . Using \b-\b on the other hand matches the - in nine-digit and pass-key .


2 Answers

You can use the regex:

^".*[^"]$

Explanation:

^     Start of line anchor
"     A literal "
.*    Any junk
[^"]  Any non " character
$     End of line anchor
like image 79
codaddict Avatar answered Sep 25 '22 18:09

codaddict


There you go:

^".*[^"]$

^" starts with "
.* some chars (or none)
[^"]$ doesn't end with "
like image 30
dda Avatar answered Sep 23 '22 18:09

dda