[JS - CS4] Help w/ JS choking on quotes in strings & regex
Does anyone have an easy way to extract text from a string with quotes in JavaScript? I seem to have run into a few limitations in the implementation of javascript's regex and how a script handles a string with quotes in it.
Here's what I'm working with: a regular string like:
{appliedParagraphStyle:"Headline 6", changeConditionsMode:1919250519}
from which I'd like to extract just the text 'Headline 6' without any quotes
I came across a regex that would get just the text without the quotes, but apparently Javascript does not support lookbacks. For instance, Jongware's wonderful WhatTheGrep script can decode this regex:
(?<=")[^"]*?(?=")
but ID finds nothing with it when run in a GREP search. The same search without the lookback finds stuff:
"[^"]*?(?=")
but what it finds still has the quote at the start of the string.
I thought I could just use substrings to extract the text without the quote, but apparently this has issues. See these examples from the Javascript console:
testStr;
Result: "Headline 6"
testStr.length;
Result: 1
testStr;
Result: Headline 6
testHL.length;
Result: 10
testHL;
Result: "Headline 6
testHL.length;
Result: 1
So if the string has a quote mark in it, it doesn't return the true length, so I can't code a start and end of the string to extract the part without the quote.
Do any of you more experienced folks have some magic insight? TIA!