Reputation: 42300
Bear with me, I am new to regular expressions, so my syntax may be slightly out.
Here is my expression:
"(?:\\s*[\"]?[']?\\s*)"
Which equates to: Any amount of white space, then the possibility of a double quote, then the possibility of a single quote, then any amount of white space.
The problem I have is that this still matches even if there is no double quote or single quote.
How do I make my expression so that there must be at least 1 double quote OR at least 1 single quote?
Upvotes: 3
Views: 1382
Reputation: 32296
If you mean you want to find one single or one double quote then just put both inside a character group and don't put a question mark after it.
(?:\s*[\"']\s*)
If you mean you want 1 or more single quotes or 1 or more double quotes
(?:\s*([\"]+)|([']+)\s*)
If you mean you want 1 or more single or double quotes
(?:\s*[\"']+\s*)
Upvotes: 1