locked
JS RegEx RRS feed

  • Question

  • User-1826049516 posted

    Hey,

    How can I get this to have and | or as complete words only. If the string after the : contains 'and' or 'or' is breaks? I've tried \b

    https://regex101.com/r/CvMmoz/5

    Sunday, May 13, 2018 11:34 AM

Answers

  • User-1826049516 posted

    This is what am expecting:

    https://imgur.com/U7mrDeT

    Actually, I figured it out. When using | for multiple words, each word has to have the \b around it. You can't put it around the options.

    If was doing ...\band|or\b... but you need to do ...\band\b|\bor\b...

    Or, managed to wrap it around both words: https://regex101.com/r/CvMmoz/6

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 9:09 AM

All replies

  • User36583972 posted

    Hi ldoodle,

    How can I get this to have and | or as complete words only. If the string after the : contains 'and' or 'or' is breaks? I've tried \b

    What kind of results do you always want to get?

    Please provide a detailed description about the results you want to achieve.

    please refer the Regular Expressions and make a try.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

    Best Regards,

    Yong Lu

    Monday, May 14, 2018 7:27 AM
  • User-1826049516 posted

    This is what am expecting:

    https://imgur.com/U7mrDeT

    Actually, I figured it out. When using | for multiple words, each word has to have the \b around it. You can't put it around the options.

    If was doing ...\band|or\b... but you need to do ...\band\b|\bor\b...

    Or, managed to wrap it around both words: https://regex101.com/r/CvMmoz/6

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 9:09 AM