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 because: only
Tag: regex
Javascript Regex – Get All string that has square brackets []
I have string data below: I need to get all strings that contain square brackets []. This is the result that I want. I’ve tried using regex /[(.*?)]/, but what I’ve got is an only the first array element is correct, the next elements are basically the same value but without the square brackets. What regexp should I use to
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 begins also. So I need regex that will get me
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?
Match non printable/non ascii characters and remove from text
My JavaScript is quite rusty so any help with this would be great. I have a requirement to detect non printable characters (control characters like SOH, BS etc) as well extended ascii characters such as Ž in a string and remove them but I am not sure how to write the code? Can anyone point me in the right direction
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 denote a function in this scenario and we
search and replace text inside html of div in javascript but not text inside tag
I’ve some HTML structure and i want to search particular text inside that HTML structure. see below example Now if I’m searching for “span” text then, “span” word should be wrapped with div tag. But only “span” word in text and not from class or other tags. i want output like this (wrap using div or span) Answer I have
RegExp A z doesnt work, but thats what Rails 4 requires
I recently switched to Rails 4 and the security requirements no longer seem to allow the use of regular expressions in the style of /^..$/. The error states that regular expressions should instead be written in the style of /A..z/. Making this change seems to resolve all of my server side validation issues, but unfortunately it also broke all of
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 literal.
Concrete JavaScript regular expression for accented characters (diacritics)
I’ve looked on Stack Overflow (replacing characters.. eh, how JavaScript doesn’t follow the Unicode standard concerning RegExp, etc.) and haven’t really found a concrete answer to the question “How can JavaScript match accented characters (those with diacritical marks)?” I’m forcing a field in a UI to match the format: last_name, first_name (last [comma space] first), and I want to provide