Skip to content
Advertisement

Tag: regex

Regex – Extract the first word from a string

I want to parse the text below: Recipient Name: Tracy Chan SKU: 103990 I want to extract “Tracy” only, the first word after “Recipient Name:” as the first name So I got as far as /(?<=Recipient Name: )(.*)(?= SKU)/gm but it only gives me “Tracy Chan”…. Using the ECMA option in Regex101… Appreciate any help on this. Thanks, Tracy Answer

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 some assumptions: keep 2 leading and trailing chars of the name

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 should work and on some regexp testing places it matches

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” The regex that I have at the

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 finding to last . Note: these are other examples: at LoggerService.log (/Users/apps/api/webpack:/pcs-goc-api/pcs-libs/logger/src/logger.ts:107:29) expected: logger at LoggerService.log (/Users/apps/api/webpack:/pcs-goc-api/pcs-libs/logger/src/logger.js:107:29) expected: logger

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 between the brackets and get the following word: Example 2: i

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

Advertisement