RegEx searched string includes backslash

  1. 2 weeks ago

    How can I search a string of lettres and numbers in RegEx, that includes backslashes?
    This does not work:(?X:.+)
    I am just not able to find a wildcard for \

    A dot doesn't match a newline unless you tell it otherwise through RegEx.Options or a switch, but this pattern may be all you need:

    \{\\colortbl[\\\w;\r\n\x20]*\}

    BTW, you can match anything literally by putting it between \Q and \E, for example:

    \Qthis+that?\E
    ... matches ...
    this+that?
  2. Beatrix W

    Mar 22 Pre-Release Testers, Third Party Store Europe (Germany)

    You can escape the backslash by doubling it: \\

  3. Edited 2 weeks ago

    Thanks Beatrix. But I can't escape them, as they are in a variable string I am searching. I would need a wildcard for the backslash. Strangely, \x7B\x5Ccolortbl(?X:.+)\x7D works on this string:

    {\colortbl\red0\green0\blue0;}

    While it doesn't work in this one:

    {\colortbl;\red255\green255\blue255;\red128\green128\blue128;\red255\green250\blue131;\red0\green0\blue0;
    \red255\green255\blue10;\red255\green255\blue10;\red0\green0\blue0;}
  4. Beatrix W

    Mar 22 Pre-Release Testers, Third Party Store Europe (Germany)

    What do you mean with wildcard? What is your purpose?

  5. Greg O

    Mar 22 Xojo Inc scout.galaxy.barn
    Edited 2 weeks ago

    Maybe this would be easier if you gave an example of your data and what fragments you are trying to extract from it so people could experiment.

  6. Edited 2 weeks ago

    @Beatrix: A wildcard according to Xojo documentation is for example a dot "." =Any single character except a line break, including a space.

    @Greg: May search Pattern and two different strings to search I posted two posts above. I am trying to extract the whole strings.

  7. Beatrix W

    Mar 22 Pre-Release Testers, Third Party Store Europe (Germany)

    The wildcard always is ".". It includes the \. That's why I was asking what you mean.

    Split your string by \ and remove the brackets.

  8. Kem T

    Mar 22 Pre-Release Testers, Xojo Pro, XDC Speakers, MVP Answer Connecticut

    A dot doesn't match a newline unless you tell it otherwise through RegEx.Options or a switch, but this pattern may be all you need:

    \{\\colortbl[\\\w;\r\n\x20]*\}

    BTW, you can match anything literally by putting it between \Q and \E, for example:

    \Qthis+that?\E
    ... matches ...
    this+that?
  9. Dear Kem, as ever you are the best and I can learn a whole lot from you! Thanks.

or Sign Up to reply!