Regular. How to determine the presence of a certain fragment inside []?

  • 0
    I have the following problem, there is some text that needs to be checked for the presence of non-alphabetic characters, but possibly having numbers and the "_" symbol, for this a simple regular pattern like the following worked:
    ^ [\ W \ d \ _ ] + $
    Further, it was also necessary to take into account that a piece of text can have an html representation of a character, for example & amp; amp; , which is easily determined, but I just don't know how to make this fragment take into account inside the square brackets of the regularity. Tried it like this:
    ^ [\ W \ d \ _ (\ & amp; amp \;)] + $ (for starters, I wanted to just & amp; amp ; defined), but in this way the regex does not define a fragment in parentheses, but simply one of the characters in those parentheses.
    The question is how to compose a regular line so that it correctly detects the presence of a given html character code, while the rest of the text should not contain any alphabetical characters.
    For example, here is the text that this regular should correctly define:
    _==+_)([email protected]#$%^&!///......000

    , but the text that should not match the regular.
    _==+_)([email protected]#$%^&!///......000

    I hope for your help. I have nothing to do with myself, I have been sitting for half a day over this problem and all without results.
    Thanks to everyone who responds!
    C++ Anonymous, Apr 20, 2019

  • 1 Answers
  • 0
    ^ ([\ W \ d \ _] | \ & amp; amp \;) + $

    This regex does not solve the problem with the "fragment inside []", but the mentioned lines should be processed normally.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!