Matching Ending Items

Sort by

recency

|

93 Discussions

|

  • + 0 comments

    why did + did not work? why must it be *? The rules are not clear?

    ^(?i:[a-z])+s$

    Write a RegEx to match a test string, , under the following conditions:

    should consist of only lowercase and uppercase letters (no numbers or symbols). should end in s.

    ===========================

  • + 0 comments

    Java 15

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class Solution {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            Pattern pattern = Pattern.compile("^[A-Za-z]*s$");
            Matcher matcher = pattern.matcher(scanner.nextLine());
            boolean found = matcher.find();
            System.out.println(found);
        }
    }
    
  • + 0 comments
    Regex_Pattern = r'^[A-Za-z]*[s]$'  # Do not delete 'r'.
    
    import re
    
    print(str(bool(re.search(Regex_Pattern, input()))).lower())
    
  • + 0 comments
    Regex_Pattern = r'^[a-zA-Z]*s$'	# Do not delete 'r'.
    
    import re
    
    print(str(bool(re.search(Regex_Pattern, input()))).lower())
    
  • + 0 comments

    Works on Python 3.6 and newer:

    r"^(?i:[a-z])*s$"