in reply to Re: Re: Re: Capturing everything after an optional character in a regex?
in thread Capturing everything after an optional character in a regex?
since, as in my original code, I only want to grab non-whitespace
Your original question was, "How can I capture everything after an optional character?" Your code didn't work. Were we supposed to look at your broken code and inuit which parts of it should be considered a specification of your requirements?
Also, as I said before this is part of a larger regex so I can't use begin/end of line characters.
You did not say that. You said, "This is a smaller part of a larger regex and I'm looking for a regex solution." There isn't a word there about not being able to match the end of the string. Furthermore, in your "clarification", you went on to say, "If X is not there I want the whole string." Were we supposed to interpret that to mean "the whole string up until some other portion matched by another part of a larger expression?"
There are many here that would be happy to help you, but you need to effectively communicate what you want help with. Don't take shortcuts by giving us a minimal example if a solution to it isn't really what you need. Don't assume we will understand your problem; make it perfectly clear. Be careful to say what you mean. Remember, you are intimately familiar with your problem and we aren't. We can't read your mind.
Maybe you've already gotten an answer you can use. Maybe you've gotten an answer that you think is right but which may fail in some cases you haven't considered. Maybe you haven't gotten an answer at all. In any case, my suggestion to you is to repost your question as another SoPW node, but this time be complete in your request. Tell us the whole problem. The very fact that you thought we could easily give you part of a larger regular expression without knowing how it would fit into that larger expression reveals that you probably have a fundamental misunderstanding of how regular expressions usually work. Reasonably complex regexen generally don't just fit together like building blocks. Changing one small part may cause drastically different behavior.
-sauoq "My two cents aren't worth a dime.";
|
|---|