Skip to content
Advertisement

Tag: regex

Split URL that contains more than one comma javascript

Basically I try to split a string of URL that contains more than one Comma, but the result turns out to be like this: Here is my code, is there a way to fix it…. URL Before splitted: Answer Since we know the url starts with https:// we can check each segment for it and build up url accordingly:

String tokenizer method

Consider strings with this format: where id, string1, string2 and string3 can be string of variable length, and extension is an image extension type. For example, two possible strings could be: I need tokenizer method in JavaScript for an express/nodejs API that takes these strings in input and outputs an object with this format: For the example strings this tokenizer

Find and detect a pattern in a string

I’m looking for a function that detects repeated patterns on a string, for example, if the input is: it should return true as there are many times repeated “Hello” or “Hello this is a repeated pattern” I have tried something like this: but that will only detect if the text contains the same character many times. Any idea or suggestion?

RegEx: Match numbers greater or equal than 1001

I would like to match numbers greater than or equal to 1001(or ‘1001’). I tried the following pattern “^(^[1-9][0-9]{3,4}$)$”. It matches from 1000 and above. Answer Short Explanation (?!^1000$) Except the number 1000 ^[1-9]d{3,}$ Match 4 and more length numbers JavaScript Example See the regex demo

RegEx how I can find these 3 groups?

I have a string with three different texts inside the exact line, separated by a _ I want a regex to extract the first part of the data, a regex for the second, and one for the last part. The string is like xxxxxx_yyyyyyy_zzzzzz (where x, y, and z it’s random data). I have tried this: But I can only

Using regex to get all consonants until a vowel appears

I’m trying to create a higher order function that would do two things. First: it would check the first letter of a string if it’s a vowel, if it is, it would append at the end of the string ‘way’. I’ve done so with this code: Then I need to code to run a specific task while checking for consonants

Format phone number in Javascript

I need to format phone number for example by replace(): From: +48 XX XXX XX XX where X is a number. Example: +48 12 345 67 89 To: +48 XXX XXX XXX Example: +48 123 456 789 Edit: My work: First, I tried to remove the spaces in string: phone.replace(‘ ‘, ”);: Before: +48 12 312 31 23 After: +4812

Regex solution for matching groups does not work

Imagine a text like in this example: I need a REGEX pattern which will match the parts in [[ ]] and I need to match each part individually separated by commas. I already tried but it doesn’t work as expected. It matches only the full string and have no group matches. Also it has a catastrophic backtracking according to regex101.com

Advertisement