Skip to content

Tag: regex

Masking of email address using reg expression

Trying to develop masking for email address using reg expression but not able to achieve the desired result. Input : harrypotter@howarts.com After masking I am looking for result something like this: What I tried is this reg expression: Answer Your question needs some clarification. Here is an answer making s…

Replace string between two time values

I am trying to clean up broken VTT files, where the lines show: 00:00.000 — constituent 00:06.880 but instead should show 00:00.000 –> 00:06.880 VTT is written so that it’s MM:SS:MSMSMS, and minutes can be any value, so I tried to match that via a regexp using ^d+:d+.d+$, which apparently…

JavaScript regex get + – * / after a number

Hey I want to make a simple calculator. The calculator should do negatives and so I want to split my input string where I match a “+ – * /” Input is for example “5+-3” so I want to match only the “+” because the “-” is part of my second number “-3&#8…

Extract text between last slash and last dot using regex

I have string like this in javascript at LoggerService.log (/Users/apps/api/webpack:/pcs-goc-api/pcs-libs/logger/src/logger.service.ts:107:29) I want to extract logger.service from it. the formula is between last / to last . I can extract from last / using /([^/]+$)/g but don’t know how to limit the fin…

Regex to get the word after brackets

I would like to have a Regex select the next word after brackets containing letters. There can be more than multiple brackets following each other before the next word. Example: [X]word[y][Z]another Expected output: word, another I would like also to achieve the same but providing the regex the content betwee…

Regex (JS) : character appears no more than N times

I have the following string : In this string, I would like to replace the 0s that appear less than 6 times one after the other. If they appear 6 times or more, I would like to keep them. (Replace them with a dot for instance) The end result should then be I thought about using the negative lookahead and