regex - How to find 2 or more consecutive words which are in caps whereas remaining words are non-caps -


I'm trying to solve this problem using RegExp. I'm sure it can be easily solved in Java and many other languages. However, I use this example RegExp

wants to about 4 below to learn more input sentences like:

  1 ABC Abcabc 123,00 tests ABCDTEST XYZTEST XY 2. ABC Abcabc 24DD test ABCDTEST XYZTEST XY test 3. ABC Abcabc test ABCDTEST XYZTEST 4. ABC ABCABC test ABCDTEST XYZTEST  

as I got word that you want to match:

  1 ABCDTEST XYZTEST XY 2. ABCDTEST XYZTEST XY 3. ABCDTEST XYZTEST 4. (only finally satisfies condition b) (no match, because all of them Statistics are characters)  

You will find it helpful to get start offset and end offset of the match.

For simplicity, suppose that only one match will be present. I.e., this will not be

  5. ABC Abcabc 123,00 test ABCDTEST XYZTEST XY AGAB WXYZ ABCDE  

However, if any input you like additional credits It can also solve.

It looks like my initial Rijksmuseum (which is false)

  (([AZ] +) {2}) {2}  

If there are no two matching patterns in a row:

  ^ (? = . * [Az]). *? (\ B [az] + (?: \ H + [az] + \ b) +)  

will store the results in the previously occupied group. If your string is multi-line and you want to consider the line by line, use g (do not stop on the first match) and m (multipurpose) flags.

Demo:

Explanation

  • ^ (? =. * [Az]) : Checks at the beginning of the line that there is at least one lowercase letter.
  • (\ b [AZ] + (?: \ H + [AZ] + \ b) +) :
    • \ b [AZ ] + : Checks that all caps are the word ...
    • \ h + [AZ] + \ B : ... at least one location ( \ h is small for horizontal space, i.e. white spaces, tabs ... but no new line) is no different than all other caps ...
    • < Code> (?: \ H + [az] + \ b) + : ... possibly all other caps terms ( (?:: is a non-capturing group)

    Alert

    \ B Accessories abc-ABD ABD If this is happening, then you can replace regex:

      ^ (? =. * [Az]). *? ((?: ^ | \ H +) [AZ] + (?: \ H + [AZ] + (? = \ H + | $)) +)  

    Correction

    It does not make any sense, nor does it solve the "two matches in a row" problem, feel free to comment!


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -