Skip to content

Tag: regex

Find passwords values in JSON objects using Regex

I have a big JSON object which contains a lot of different JSON, most of them have the structure below (key: sometext-v1.password, and value: password for example: I want to use Regex to extract all passwords by a name which contains ‘password’ string and its value, but I don’t want to itera…

Regular expression to match optional patterns

I know that Regex is a pretty hot topic and that there’s a plethora of similar questions, however, I have not found one which matches my needs. I need to check the formatting of my string to be as follows: All line must start with 5 digits. Characters 6 to 12 must be white space. Character 13 must be ei…

Java regular expression to match valid Java identifiers

I need to create a regular expression able to find and get valid identifiers in Java code like this: I have tried to add multiple regexes in a single regex, but how can I build a pattern to exclude reserved words? I tried this regex ^(((&&|<=|>=|<|>|!=|==|&|!)|([-+=]{1,2})|([.!?)}{;,(-…

Allow only left aligned zeros using regex

I am fairly new to using regex. I have a serial number which can take the following forms: VV-XXXXXX-P or VVXXXXXXP If the hyphen variant is used, then the number of ‘X’ can be variable. For example 01-162-8 is equivalent to 010001628. In order to identify the 2 formats, I have created the followi…