Skip to content
Advertisement

Tag: regex

Java PathMatcher not working properly on Windows

I try to implement a JUnit test for my SimpleFileVisitor but the used PathMatcher doesn’t work properly on Windows. The problem seems to be the PathMatcher with a regex pattern behaves different on Linux and Windows: But I’ve a longer list in my regex for multiple files which are not easy to migrate to glob syntax. Otherwise I’ve nested groups

Java and regex lexer

I am trying to make some sort of Lexer in Java using regex for a custom markdown “language” I’m making, it’s my first time working with this stuff so a little lost on a few things. An …

Splitting a string using special characters and keeping them

I’m trying to split a string with special characters and not being able to split the parentheses properly. This the code I’m trying : The regex does not split the starting parentheses ( I’m trying to get the following output: Could someone please help me. Thank you. Answer So you want to use split() to get every character separately, except

Regex to match any number unless it is part of a specific string

Sorry if this is a dupe, I did search but couldn’t seem to find something that matched my query. I have a replacer function in java that runs multiple regexes to find and replace specific strings. One of them is looking at numbers, and if it finds a number it adds space around it, for example; test123 > test 123

Regular expression to mask email except the three characters before the domain

I am trying to mask email address in the following different ways. Mask all characters except first three and the ones follows the @ symbol. This expression works fine. (?<=.{3}).(?=[^@]*?@) abcdefgh@gmail.com -> abc*****@gmail.com Mask all characters except last three before @ symbol. Example : abcdefgh@gmail.com -> *****fgh@gmail.com I am not sure how to check for @ and do reverse match.

Regular expression in Java for parsing money

I’m looking for are regex for parsing money amounts. The String s10 should not match. Can someone help, or can someone simplify the regex? That’s my try: Answer I think you may use See the regex demo Details (?<![d,.]) – no digit, . or , allowed immediately on the left (?:d{1,3}(?:(?=([.,]))(?:1d{3})*)?|d+) – d{1,3}(?:(?=([.,]))(?:1d{3})*)? – one, two or three digits followed

Advertisement