I’m having trouble getting this Javascript Regular Expression to work.
What i want is to find a character that starts with @" has any characters in the middle and ends with ". I will also need it in a single quote from.
The tricky part for me, is that it cant be starting with @" and ending with " because the string it’s looking through could look like [UIImage imageNamed:@"glass-round-red-green-button.png"].
So far what i have is this.
regex: new RegExp('\\@"?\\w+\\b"*', 'g')
Try this regular expression:
An explanation:
@(["'])matches either@"or@'[^]*?matches any arbitrary character ([^]contains all characters in opposite to.that doesn’t contain line-breaks), but in a non-greedy manner\1matches the same character as matches with(["'])Using the literal RegExp syntax
/…/is more convenient. Note that this doesn’t escape sequences like\"into account.