Skip to content
Advertisement

Tag: regex

How to match multiple words in multiple lines

I have a multiline text, e.g. I need to see if two words present in whole text (AND operator). I tried something like: Answer You can try this regex: [sS] matches literally everything, encluding line wraps b is the word bound, so word1 count but sword1 does not. And since you treat all the lines as a whole, you dont

Validate Range of Numbers

I am trying to validate a comma separated list of numbers 1-384 unique (not repeating). i.e. 1, 2, 3, 5, 6, 7, 9 is valid 1-3, 5-7, 9 is valid 2, 2, 6 is invalid 2, is invalid 1, 2, 3, 4, 15, 6, 7, 385 is invalid because the last number is more than 384 I have tried the

Match specific string which not contains specific pattern

I have urls and want to match only those which match this pattern but not contains this type=inbox – so for example – regexp should give following results: I try this but get wrong results (good only when type=inbox is at the end of string) How to do it using JavaScript RegExp? Answer The pattern that you tried asserts that

Need help to match regex with conditional concatenation (JS)

I need help to accomplish the use cases of this regex: https://regex101.com/r/HmDQHJ/3/ Right now, my issue is that I need to match this: But also fail on this: Can someone help me to accomplish this? Thank you! More context: We have an old crawler that goes project source and looks for usage of a function called “T”, then it should

what I cant splir the char of ‘(‘ using this regexp in javascipt

the var codigo have the value *int a,h;float b,c;a=b*(c+h); my regex is: and as a output im getting this: why after the ‘*’ the ‘(‘ isnt splitting right ? when the ‘)’ its doing correctly? Answer In Regular Expressions, since . represents any character, it should be enough to split by the following regex: and then remove the empty string

why is split returning empty strings even tho capturing parenthesis are not present?

My code: That outputs [“”, “a”, “”, “b”, “”]. Why are the empty strings present? Quoting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split , If separator is a regular expression that contains capturing parentheses, then each time separator is matched, the results (including any undefined results) of the capturing parentheses are spliced into the output array. However, not all browsers support this capability. That’s clearly not

Advertisement