Skip to content
Advertisement

Tag: regex

Regex to Identify Month from the first 3 letter

I have a date format of 12March2018 I am trying to get a regular expression to identify the pattern using a regex expression. 1st letter must be numeric.Followed by the first 3 letters of the month. If the word which follows the numeric matches with any first 3 letter of any month it should return true. How do I get

Dynamic Regex for Decimal Precision not Working

I have the following hard-coded RegEx expression for decimal precision & scale, which works (in another project): However, I don’t want to hard-code multiple variations. And, interestingly, the following fails…but I don’t know why. I “think” the concatenation may (somehow) be effecting the “test” What am I doing wrong here? SAMPLE: FAILING SAMPLE-SNIPPET: Answer Always look at the result when

Regex for not containing consecutive characters

I can’t figure out javascript regex that would satisfy all those requirements: The string can only contain underscores and alphanumeric characters. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. This is as far as I came, but ‘not containing consecutive underscores’ part is the hardest to add. Answer

Javascript regex get only page number from URL

i have URL like https://example.com/my-list/page/35/?a=45&b=56 I want to get page number using regex that is after /page/ in url, the result i want is 35 Answer There’s 2 easy ways you could do it using RegEx: The first way: The second way: You can also split the string, and then use regex to grab just the beginning of the string:

How to convert a string of camelCase identifiers to a string with space-separted words, while replacing the separator?

I have studied the answers to “how to use regular expressions to insert space into a camel case string” and several related questions, and the code below will produce the string Word Double Word A Triple Word UPPER Case Word Unfortunately, it’s necessary to have a separator where {TOKEN} appears in the input. Ideally, the result would have comma separators

JavaScript automatic comma

In my program, the user enters values betweeen 0 and 8. For example: if the user wants to input “3,4” he only needs to write “34”. the program will eventually put the comma in, but I have no clue how to do it. So: input = “34” –> output = “3,4” input = “09” –> output = “0,9” This is

Regex pattern for Malaysian mobile phone Number

Regex pattern ^(+?6?01)[0|1|2|3|4|6|7|8|9]-*[0-9]{7,8}$ in HTML5 input return error. I tested the regex, no errors on regex101.com as well as in my php code. But in HTML5 it does not function as it be. My code: Error: textfield.js:146 Pattern attribute value ^(+?6?01)[0|1|2|3|4|6|7|8|9]-*[0-9]{7,8}$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^(+?6?01)[0|1|2|3|4|6|7|8|9]-*[0-9]{7,8}$/: Invalid escape Anyone can help me? Thanks

Regex match HTML attributes names

I have the following element stored as a String: I want to extract all the attributes names like this: This is what I tried to do, but I get also the values and dosent match the data-animation and disabled: http://jsbin.com/hibebezibo/edit?js,console EDIT: Manged to get attributes using: But I still cant get the “disabled” prop. Can someone explain me how to

Advertisement