Positive Lookbehind

Sort by

recency

|

31 Discussions

|

  • + 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("(?<=[13579])[0-9]");
            Matcher matcher = pattern.matcher(scanner.nextLine());
            int count = 0;
            while(matcher.find())   count++;
            System.out.println("Number of matches : "+count);
        }
    }
    
  • + 0 comments
    Regex_Pattern = r"(?<=[13579])\d"   # Do not delete 'r'.
    
    import re
    
    Test_String = input()
    
    match = re.findall(Regex_Pattern, Test_String)
    
    print("Number of matches :",
    
  • + 0 comments

    My solution using typescript:

    function main() {
        // Enter your code here
        const regexPattern: RegExp = /(?<=[13579])\d/g
        const test: string = readLine()
        console.log("Number of matches : " + test.match(regexPattern).length)
    }
    
  • + 0 comments
    (?<=[13579])\d
    
  • + 0 comments

    With Python

    Regex_Pattern = r"(?<=[13579])\d"