How to match two consecutive alphabets like AA, BB not AB, BD with Regular expression in python?

Sang-il Ahn

I would like to match string of two consecutive alphabets like AA, BB not AB, BD. Python 3.x is my language. Please consider valid alphabets would be capitalized. The followings are examples for valid and not valid strings: To be honest, ^[A-Z]{2} would not work.

  • Valid: AA, ZZ, DD, EE,
  • Not valid: AB, DDD, aA, Aa, Cd, DE
Zenoo

You can use grouping to achieve that.

Here is a RegEx that will match any uppercase alphabetical character twice : ([A-Z])\1

Demo.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can i write a regular expression for to match string staring with alphabets and ending with digits

From Dev

How can i make xsl count output aa,bb,cc,instead of aa,ab,ac,?

From Dev

How to increment string like AA to AB?

From Dev

Python Regular Expression not match

From Dev

Regular expression match in python

From Dev

regular expression not containing two or more consecutive chars

From Dev

two consecutive words regular expression on PHP

From Dev

Regular Expression for not allowing two consecutive special characters

From Dev

Java regular expression matching two consecutive consonants

From Dev

match two files with regular expression

From Dev

How to match two or more dots in a string using regular expression

From Dev

How to match values using one regular expression instead of two?

From Dev

how to match two strings with regular expression in bash shell script?

From Dev

How to match two or more dots in a string using regular expression

From Dev

How to match values using one regular expression instead of two?

From Dev

Python Regular expression potential match

From Dev

regular expression match issue in Python

From Dev

regular expression match issue in Python

From Dev

How to write IF AND regular expression match

From Dev

VIM how to replace "AA" to "BB" in a file

From Dev

Regular expression in python to match an logical expression

From Dev

How to get group name of match regular expression in Python?

From Dev

How to match a regular expression with exactly one digit in it using python regex?

From Dev

How to delete all strings that match a regular expression in python?

From Dev

How to perform summation for regular expression match results in python

From Dev

How to Find The Starting Position of the Nth Match of A Regular Expression in Python?

From Dev

How to match a regular expression with exactly one digit in it using python regex?

From Dev

Match text between two strings with regular expression

From Dev

Regular expression to match everything after two words

Related Related

  1. 1

    How can i write a regular expression for to match string staring with alphabets and ending with digits

  2. 2

    How can i make xsl count output aa,bb,cc,instead of aa,ab,ac,?

  3. 3

    How to increment string like AA to AB?

  4. 4

    Python Regular Expression not match

  5. 5

    Regular expression match in python

  6. 6

    regular expression not containing two or more consecutive chars

  7. 7

    two consecutive words regular expression on PHP

  8. 8

    Regular Expression for not allowing two consecutive special characters

  9. 9

    Java regular expression matching two consecutive consonants

  10. 10

    match two files with regular expression

  11. 11

    How to match two or more dots in a string using regular expression

  12. 12

    How to match values using one regular expression instead of two?

  13. 13

    how to match two strings with regular expression in bash shell script?

  14. 14

    How to match two or more dots in a string using regular expression

  15. 15

    How to match values using one regular expression instead of two?

  16. 16

    Python Regular expression potential match

  17. 17

    regular expression match issue in Python

  18. 18

    regular expression match issue in Python

  19. 19

    How to write IF AND regular expression match

  20. 20

    VIM how to replace "AA" to "BB" in a file

  21. 21

    Regular expression in python to match an logical expression

  22. 22

    How to get group name of match regular expression in Python?

  23. 23

    How to match a regular expression with exactly one digit in it using python regex?

  24. 24

    How to delete all strings that match a regular expression in python?

  25. 25

    How to perform summation for regular expression match results in python

  26. 26

    How to Find The Starting Position of the Nth Match of A Regular Expression in Python?

  27. 27

    How to match a regular expression with exactly one digit in it using python regex?

  28. 28

    Match text between two strings with regular expression

  29. 29

    Regular expression to match everything after two words

HotTag

Archive