Loading ...
Sorry, an error occurred while loading the content.

Re: [NTS] How to search a QUESTION MARK in a regular expression

Expand Messages
  • EB
    As is so often the case, I overlooked the obvious. I thought I had tried pretty much everything - but apparently not. The seems to work. THANK YOU!
    Message 1 of 6 , Oct 10, 2012
    • 0 Attachment
      As is so often the case, I overlooked the obvious. I thought I had tried pretty much everything - but apparently not. The \ seems to work. THANK YOU!

      --- In ntb-scripts@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > \?
      >
      > Regards,
      > John
      > RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/
      >
      > From: ntb-scripts@yahoogroups.com [mailto:ntb-scripts@yahoogroups.com] On Behalf Of EB
      > Sent: Tuesday, October 09, 2012 18:01
      > To: ntb-scripts@yahoogroups.com
      > Subject: [NTS] How to search a QUESTION MARK in a regular expression
      >
      >
      > I have a bunch of lines in a file that look something like this:
      >
      > Ga53t76lah/Z3vdeg14/V0c2/?freds=OTvvA4OfhbfjI6MQ,0,0,0,&p=31
      >
      > I want to strip everything to the right of and including the QUESTION MARK using a regular expression
      >
      > / ?fred(.*)p=31 did not work as a search string in FIND.
      >
      > It did work if I removed the question mark - but that left the question mark in place after the REPLACE.
      >
      > I can - turning the regular expression block off - FIND/REPLACE the question mark with a less tricky character and then
      > run (with RegEx on) the FIND/REPLACE to get rid of everything to the right of and including the new character - but that
      > is additional steps.
      >
      > Is there a way to identify the question mark as a question mark instead of special character within the original RegEx
      > FIND/REPLACE? (The [:?:] construct did not seem to work.)
      >
      > Thank you.
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • flo.gehrke
      ... An alternative is to search the ? in hex x3F or octal 077 . Regards, Flo
      Message 2 of 6 , Oct 10, 2012
      • 0 Attachment
        --- In ntb-scripts@yahoogroups.com, Robert Bull <barlennan@...> wrote:
        >
        > Ergo, you probably need to "escape" a "?" with a backslash
        > in front of it.

        Why "probably"? It's a PCRE rule, and John is undoubtedly right. See "Backslash" in the Help on Regex:

        > If (the backslash) is followed by a character that is not a
        > number or a letter, it takes away any special meaning that
        > character may have. This use of backslash as an escape character
        > applies both inside and outside character classes.

        An alternative is to search the '?' in hex '\x3F' or octal '\077'.

        Regards,
        Flo
      Your message has been successfully submitted and would be delivered to recipients shortly.