Help needed on RegEx.Split() / pattern for dealing with an escaping char. as separator [modified]
-
Hi there, I would much appreciate if anyone could help me on this problem that is sligthly driving me crazy, I've a string ... say "abc§123§§456§§§xyz" I'd like to split it in a string[] , using '§' as separator , now the trick is that '§' is (in this case) also an 'escape' char. (i.e. in the original string "§§" represent the '§' ... and therefore is not to be considered to be a separator for splitting). So I am expecting a split like : abc 123§456§ xyz My code is (so far):
Regex regExSplit = new Regex("(? That split as abc 123§§456§§§xyz Thanks for any help :rolleyes: Marc -- modified at 4:51 Monday 16th April, 2007
-
Hi there, I would much appreciate if anyone could help me on this problem that is sligthly driving me crazy, I've a string ... say "abc§123§§456§§§xyz" I'd like to split it in a string[] , using '§' as separator , now the trick is that '§' is (in this case) also an 'escape' char. (i.e. in the original string "§§" represent the '§' ... and therefore is not to be considered to be a separator for splitting). So I am expecting a split like : abc 123§456§ xyz My code is (so far):
Regex regExSplit = new Regex("(? That split as abc 123§§456§§§xyz Thanks for any help :rolleyes: Marc -- modified at 4:51 Monday 16th April, 2007
Escape char as seperator ...maybe I'm misunderstanding the question, but wouldn't you simply type a double §§ in the regex string?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: How men in the Catholic Church replaced Passover with Easter The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Escape char as seperator ...maybe I'm misunderstanding the question, but wouldn't you simply type a double §§ in the regex string?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: How men in the Catholic Church replaced Passover with Easter The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Sorry if I was not clear enough, if I use "§§" as a pattern the split of "abc§123§§456§§§xyz" will give abc§123 456 §xyz and this is not my expected abc 123§456§ xyz To try to make it clearer let's say that in the original string a substring like "§§" is to be understood as : since a "§" is followed by another "§" , then in the result string this second "§" is to be kept as is and not considered to be a separator (think of "\" instead of "§" if you prefer : "\\" means a real '\' not to be considered as a 'special' char. ... but that makes things quite unreadable in regex patterns) Thanks Marc hooktrack.girollet.com
-
Sorry if I was not clear enough, if I use "§§" as a pattern the split of "abc§123§§456§§§xyz" will give abc§123 456 §xyz and this is not my expected abc 123§456§ xyz To try to make it clearer let's say that in the original string a substring like "§§" is to be understood as : since a "§" is followed by another "§" , then in the result string this second "§" is to be kept as is and not considered to be a separator (think of "\" instead of "§" if you prefer : "\\" means a real '\' not to be considered as a 'special' char. ... but that makes things quite unreadable in regex patterns) Thanks Marc hooktrack.girollet.com
I tried a couple of different regexes but wasn't able to accomplish this. Perhaps this is better asked in a regex forum?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: How men in the Catholic Church replaced Passover with Easter The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
I tried a couple of different regexes but wasn't able to accomplish this. Perhaps this is better asked in a regex forum?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: How men in the Catholic Church replaced Passover with Easter The apostle Paul, modernly speaking: Epistles of Paul Judah Himango