Skip to content

Tag: regex

Regex for matching HashTags in any language

I have a field in my application where users can enter a hashtag. I want to validate their entry and make sure they enter what would be a proper HashTag. It can be in any language and it should NOT precede with the # sign. I am writing in JavaScript. So the following are GOOD examples: Abcde45454_fgfgfg (good…

JavaScript Regex to capture repeating part of decimal

Looking for the best way to take an arbitrary number with potentially repeating decimal part, and discover the repeating part (if present). Ultimately, I need to decorate the number with overline notation (either with css text-decoration or MathML mline), so I need to know the index of where the repetition be…

Javascript: Named Capture Groups

I need to match an expression and extract values from it using named groups. Lets say this is my string: So i want to match it using regex and extract the element and value. I know how to do it is c#, I am trying to figure it out in JS. This is my regex: What am I doing wrong?

REGEX to match only VALID EXCEL COLUMNS (A-XFD)

Ok, I have ANOTHER REGEX question for everyone. I have a field that has multiple validation steps. The first step is to ensure it isn’t blank, second is to ensure that only between 1 and 3 CAPITAL LETTERS are entered, and third, to ensure it doesn’t contain “[” (an opening bracket will…

regexp to allow only one space in between words

I’m trying to write a regular expression to remove white spaces from just the beginning of the word, not after, and only a single space after the word. Used RegExp: Test Exapmle: Only one space should be allowed. Is it possible? Answer BTW, new RegExp(..) is redundant if you use regular expression liter…