Skip to content
Advertisement

Tag: regex

Regex for String in React

How shall we write a regular expression to validate a string that should have a length of a minimum of 1 character and a maximum of 50 characters, have both upper case and lower case, alphanumeric, include space, and have mostly used special characters like @,._-&$#? The first character should be either alphabet or number then the rest can be

Remove dots and spaces from strings

I want to remove dots . and spaces with regex text.replace(/[ .]+/g, ”). This is an 8-string 12.34.5678; and this is another 13-string 1234 5678 9123 0 okay? But the main problem is that it removes all dots and spaces, from the sentence. Thisisan8-string12345678;andthisisanother13-string1234567891230okay? an 8-string 12.34.5678 another 13-string 1234 5678 9123 0 Needs to be converted to. an 8-string

regexp highlight search matching numbers

I’ve got a script from a friend, and tried to modified it. So that it highlights a string of numbers in a div. The problem is, that the output of the highlighted text becomes the regexp. Any solutions, what I’m doing wrong? https://jsfiddle.net/rrggrr/kgd4swha/6/ Answer Here’s a simple way of doing it: Use a string#replace using /(9756[0-9]{8})/g as the regex to

Is it possible to give Regex a min Value? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Hey I have a working regex that really does the job it should. One thing I would like to add or change is that the

How to extend regex to accept @ in image urls

I have a regex for validating image urls, however some of the images are using @ for example: https://test.com/image-name@2x.jpeg. How can I extend this regex to accept also the @ character inside of the image link? Current regex look like this Answer If it can only be part of the image name, you can add a forward slash followed by

Javascript use RegEXP to remove characters between (but not including) special characters

I have a string as follows: I’m trying to get rid of the characters between the backslashes. Wanted result: I know how to remove everything except characters between two special characters WITHOUT removing the special characters. Every answer on stack includes removing them too ๐Ÿ™ Answer Put the backslashes in the replacement string. Note that you need to double them

Advertisement