i want to match all the text in both "" and ''. My text may contain any of these so i used or operator My regular expression is as follows
(\"(.*?)\"|'(.*?)')
to retrieve the text between quotes i have used groups like RegExp.$2 for "" and RegExp.$3 for '' Now using only one group can i retrieve either of these. For example i might not be knowing when "" is given and '' is used so can any one suggest a regular expression which satisfies the above mentioned property.
Something like this?
(["'])((?:(?!\1).)*)\1
First backreference will contain "
or '
while the second one will contain the text between quotes.
And if this is code you want to match (strings between quotes), you may want to handle backslashes:
(["'])((?:(?!\1)[^\\]|\\.)*)\1