Code Comments
Programming Forum and web based access to our favorite programming groups.What's the syntax for RegEx to specify that I want to match something that's NOT a string I specify? Example: "HELLO WORLD" RegEx (wanted) = select string that is NOT "WORLD" Result: "HELLO "
Post Follow-up to this messageYour example looks more like you want to remove a substring from a string
rather than select a string
Result = Replace("HELLO WORLD", "WORLD", "")
Is this what you mean?
"Art" wrote:
> What's the syntax for RegEx to specify that I want to match something that
's
> NOT a string I specify?
> Example: "HELLO WORLD"
> RegEx (wanted) = select string that is NOT "WORLD"
> Result: "HELLO "
>
>
Post Follow-up to this messageSorry I couldn't reply sooner. My IE browser quit displaying the threads..."error on page" don't know why. I finally loaded FireFox (agains t Company rules, but so what) Without seeing exactly what you are trying to do I'm somewhat at a loss. I haven't ever used regular expressions. There may be a pattern syntax that does what you want. I thought somebody else might've replied by now. How would I do it? The old fashion way... I'd probably break up processing the string into several steps or loops to remove what I want removed using the Replace function, or manually, etc. Maybe not slick but if it gets the job done...who knows maybe I'd get a pay raise! (Yeah, right) "Art" wrote: > Charlie, > Unfortunately not. I specifically simplified this regex to make my questio n > easily understood. The procesing instructions for the string in question a re > far more complicated and trying to illustrate it w/ concrete regex can be > difficult to decrypt. So I thought that if I present the opposite then it > will be easy to understand. > Basically regex will have to replace all non-alphanumeric characters BUT > will also have to bypass the patterns which I would specify. > I know how to negate individual (or set of) characters but how can you > accomplish the same w/ whole strings? > For example I can't say regex = [^WORLD] becuse the result is going to be HE > instead of HELLO. So, how do you negate whole strings instead of individua l > charactes. > Thanks for you help thou! > > "Charlie" wrote: >
Post Follow-up to this messageUse regex replace - set the regex syntax such that it finds the things you want to eliminate and replace them with "". "Art" <Art@discussions.microsoft.com> wrote in message news:E3D45237-CE29-4C42-B5B6-66591BDA3A4A@microsoft.com... > What's the syntax for RegEx to specify that I want to match something > that's > NOT a string I specify? > Example: "HELLO WORLD" > RegEx (wanted) = select string that is NOT "WORLD" > Result: "HELLO " > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.