regex - Java - Split string based on space and single quote but ignore two single quotes -
i want split string using space , single quote. 2 single quotes should ignored.
input:
name eq 'a''b'
output should be:
name eq a''b
i tried use
[^\\s\"(?<!')'(?!')]+|\"[^\"]*\"|(?<!')'(?!')[^(?<!')'(?!')]*(?<!')'(?!')"
but not work.
the following 1 should suit needs:
'(?:[^']|'')+'|[^ ]+
java example:
string input = "foobar foo bar 'foobar' 'foo bar' 'foo''bar'"; pattern pattern = pattern.compile("'(?:[^']|'')+'|[^ ]+"); matcher matcher = pattern.matcher(input); while (matcher.find()) { string match = matcher.group(); system.out.println(match); }
Comments
Post a Comment