Skip to content

Tag: regex

Java Regex to match Chinese and/or ordinary numbers

Actually the regex I have matches anything but the Chinese but it matches the numbers too, which I don’t want. As you can see in the regex demo here, the number 45 is matched but I need it to be excluded too. https://regex101.com/r/XNtD12/1 Current regex is: (?!p{IsHan}n)[^p{IsHan}n?。,?!]+ Desired outpu…

How to correct the string returned based on a regex

Here is the message and Type message Type IND SMD 0402 1.2nH 50pH 390mA 100MOHM MAG What i’m trying to return is the 1.2nH For that i created a function as below This is returning me 50pH but actually i’m trying to return 1.2nH How could i correct my function ? Answer If you use the code to check …

Get all possible matches in a regex match (In Java)?

I am using a regex to match few possible values in a string that coming with my objects, there I need to get all possible values that are matching from my string as below, If my string value is “This is the code ABC : xyz use for something”. Here is my code that I am using to extract matchers,

Pattern-Matcher is not looking for all matches for some reason

I have, it seems, a very easy task, with which Matcher for some reason does not cope. So, the task sounds like this: You need to find and display all the substrings from the string “AAABBBB”, where there are pairs of AA or BB, while they can go in a row or alternate “AABBBBBBAA”. Eithe…

Splitting String by column with regex

This is a String I get as input, but I just need every column, starting with the second column, aka: 1 (second row) 2 and 1 (third row) 1 (fifth row) This String has no fixed size in how many lines there could be or how many columns (columns being split by one space). I think this is fairly easy

Validate string like “abc=def,123,xyz” with regex

I would like to verify the syntax of an input field with a regex. The field should accept text like the following examples: There has to be a word, a = sign and a list of comma separated words. The list must contain at least one entry. So abc= should be invalid, but abc=123 is valid. I am using a

What would be the Regex to match following 6 digit numbers?

The numbers should be 6 digit and of the form 0x0x0x or x0x0x0, where x can be any digit from 1 to 9. Ex – 202020, 030303, 808080, etc. I have this regex that matches numbers with alternative 0 and 1s, cannot make it work for the above use case Answer The easiest way is probably to capture the repeating