Matching Anything But a Newline

Sort by

recency

|

403 Discussions

|

  • + 0 comments
    regex_pattern = r"^...\....\....\....$"
    
    import re
    import sys
    
    test_string = input()
    
    match = re.match(regex_pattern, test_string) is not None
    
    print(str(match).lower())
    
  • + 0 comments

    The regex pattern you're looking for is ^...$ — this matches exactly three characters, each of which can be any character except a newline. Golden 365

  • + 0 comments

    regex_pattern = r'^.{3}..{3}..{3}..{3}$'

    we need to use ^ at the start and $ at the end as we search for exact match in the entire test_string

    test_string must be in the required format and there is only one occurence of the required string we are searching for.

    I hope I explain it well

  • + 1 comment

    either of these would do

    regex_pattern = r"^(.{3}\.){3}.{3}$"	# Do not delete 'r'.
    regex_pattern = r"^...\....\....\....$"
    
  • + 0 comments

    My regex:

    ^((?:[^\n]{3}.){3}(?:(?:[^\n]){3}))$