angularjs - String trimming in Javascript -


i have api returns json string. want part of string returns.

it returns car style

"s 4dr sedan (1.8l 4cyl 4a)" "ce 4dr sedan (1.8l 4cyl 4a)" "le 4dr sedan (1.8l 4cyl 5m)" "le 4dr sedan (1.8l 4cyl 4a)" 

i want "string out" in parentheses. havent worked javascript string editing have no clue on how this. please help.

(any tips cool too)

ps: im working angularjs

you should check out regular expressions, can select bits of string want , drop rest, not sure if wanted text in brackets or wanted that, sample uses stuff before brackets. can play around regex here, put sample in there:

https://regex101.com/r/lt8fb3/1

if want use within brackets replace \1 in substitution string \2

in java then:

string updated = your_json_string.replaceall("\"\s?(.*)\s\((.*)\)\"", "$1");  

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -