SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
JDBCSupport - An easy to use, light-weight JDBC framework -
which is close but where are the two a letters?
Henry Wong wrote:
which is close but where are the two a letters?
The two a letters were used as part of the delimiters.
Try...
Henry>
JDBCSupport - An easy to use, light-weight JDBC framework -
Rob Prime wrote:First of all, I do not believe you if you say that using "|" will work. The vertical bar is a meta character in regular expressions. Also, your two lines of code won't even compile, as the \ should be escaped.Post Real Code.
In the JavaDoc of java.util.regex.Pattern, do a search for lookbehind and you should find a solution. Of course this solution will again break if you do want to split at \\|, then again not at \\\| etc. That's going to be quite a bit harder.
@Henry, Thank you so much for your help. I didn't want to wite my own String splitter becuase I was certain that it could be done with regular expressions
JDBCSupport - An easy to use, light-weight JDBC framework -
Sebastian Janisch wrote:
@Henry, Thank you so much for your help. I didn't want to wite my own String splitter becuase I was certain that it could be done with regular expressions
Note though that your custom splitter could be faster than employing the heavy regex engine.
Sebastian Janisch wrote:
Henry Wong wrote:
which is close but where are the two a letters?
The two a letters were used as part of the delimiters.
Try...
Henry>
@Joe Carco ... This is what you want. ..
It will not work if a backslash is part of the text and comes just before the pipe character:
Henry Wong wrote:
It will not work if a backslash is part of the text and comes just before the pipe character:
Not exactly sure what you mean. Isn't this what the OP wanted? To not split when the pipe character is escaped?
Henry
In short: the OP might be looking for a way to split on the pipe only if the pipe has an uneven number of backslashes before it.
Rob Prime wrote:In the JavaDoc of java.util.regex.Pattern, do a search for lookbehind and you should find a solution. Of course this solution will again break if you do want to split at \\|, then again not at \\\| etc. That's going to be quite a bit harder.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Which I already mentioned:
Rob Prime wrote:In the JavaDoc of java.util.regex.Pattern, do a search for lookbehind and you should find a solution. Of course this solution will again break if you do want to split at \\|, then again not at \\\| etc. That's going to be quite a bit harder.
Henry Wong wrote:Hmmm.... How about this for checking odd number of backslashes?
Unfortunately, this can only check for odd number of backslashes up til 2001 backslashes, then it breaks...
To Joe Carco, don't you wish you wrote your own "boring" regex instead, now? ...
Henry>
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
This looks like a job for .... legal tender! It says so right in this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|