match any character except forward slash
match any character except forward slash
I'm parsing data from my satellite box to receive music information to display on my iPad. One particular string I'm interested in looks like this;
"title": ""Free Falling""
I want to match Free Falling only so that it can be displayed.
I tried
"title": "(.*)"
but it returns "Free Falling"
"Free Falling"
I tried negating the forward slashes [^/]
but the when tested, the first space between Free and Falling matches the entire pattern
[^/]
How do I match the words Free Falling only, without the quotes and forward slashes and retain the white space?
Try this
"title": "\"(.*)\""
.– Hussein Golshani
Jun 30 at 14:12
"title": "\"(.*)\""
Thank you, revo. Yes, it's JASON. I tried testing all of the responses in a regex tester and none of them match. I'll try it in my software when I get home and see if they work. Thanks again.
– meowcat
2 days ago
2 Answers
2
If the syntax is always same and such title string starts and ends with "
, then use a regex pattern
"
"title":s*"\"(.*)\""
and your desired result will be in group #1
If the "
is optional, then use
"
"title":s*"(\"|(?!\"))(.*)1"
and your desired result will be in group #2
Thanks, Omega. Yes, the syntax is exactly the same for all song titles received from the device. "(.*)"
– meowcat
2 days ago
If other entries do not have these additional "
s around the title names and you want to be able to use one regex to match titles both with and without "
s, you can use a regex like this:
"
"
"title": "(?:")?([^\"]*)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Welcome to Stackoverflow. Is it in JSON?
– revo
Jun 30 at 14:00