Define (rewind) it with the regexr tool

I am using this tool http://regexr.com/3fvg9 I want to mark this (paste) it into the regexxr tool.

       (weath)er is good.   // i want to mark this word
       (weather is go)od.   // i want to mark this word

      

Please help me.

+3


source to share


1 answer


Since there is no way to check with a regular expression if a word is "known" or not, I suggest that you first extract those parts and then use some sort of spelling dictionary to check if the words are correct. It won't be 100% accurate, but it's still better than a pure regexp.

The expression you need to extract parts of the glued words in parentheses is

(?|([a-zA-Z0-9]+)\(([a-zA-Z\s]+)\)|\(([a-zA-Z\s]+)\)([a-zA-Z0-9]+))

      



See the regex demo at regex101 which supports PHP regex.

The regex matches two alternatives within the reset branch, within which all capture groups in different branches are numbered starting with the same ID:

  • ([a-zA-Z0-9]+)\(([a-zA-Z\s]+)\)

    - group 1 ( ([a-zA-Z0-9]+)

    ) matching 1 + alphanumeric characters then (

    followed by group 2 ( ([a-zA-Z\s]+)

    ) matching 1 + letters and spaces and then )

    matching
  • |

    - or
  • \(([a-zA-Z\s]+)\)([a-zA-Z0-9]+)

    - a (

    , then group 1 ( ([a-zA-Z\s]+)

    ), corresponding to 1 + letters and spaces )

    , and then group 2 ( ([a-zA-Z0-9]+)

    ), corresponding to 1 + alphanumeric characters
+1


source







All Articles