java - Decipher this regex -
i came project working on several months ago, , 1 problem figured out when need extract part of string. string used both paranthesis , quotationmarks, couldn't split normal text.
example of how string might look:
word_object("id"): preword:subword
now wanted grab what's after ("id"):,
'preword:subword'
i found regex helped me out, , took quite time find example applicable wanted. had settle example, because tried find sources on how learn incredibly complex system failed hard @ that. regex solved looks this: "word_object(\\(\"" + "id" + "\")\\): "
i content seemed work, when got project , tried it, trying extract word used underscore _
and underscore following word(s) left out.
example, splitting text word_object("id"): preword:subword_underscoreword
using regex (using complete line now) idsplit = subtemp.split("word_object(\\(\"" + "id" + "\")\\): ");
would return: preword:subword
instead of wanted preword:subword_underscoreword
.
did somehow in regex instruct ignore after 2nd special-character (since accept :, apparently _ breaks everything)?
public static void main(string[] args) { final string[] split = "word_object(\"id\"): preword:subword_underscoreword".split("word_object(\\(\"" + "id" + "\")\\): "); system.out.println("split = " + split[1]); }
leads to
split = preword:subword_underscoreword
Comments
Post a Comment