Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a string like
Menu: apple, orange-juice, bananas
I want to use REGEX to match only apple orange-juice bananas
I have tried to search Google and regex101.com for help but still no any idea.
I would appreciate any help! Thank you
You can do the following in javascript :
var string = "Menu: apple, orange-juice, bananas";
console.log(string.replace(/Menu: |\,/g, ""))
Regex101 : https://regex101.com/r/N0AfW7/1
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have an array of strings denoting variants of shirts in my store.
Here is an example string:
Apparel-DTG-Tshirt-District-DT6000-M-Black-Mens-CF-20200304113232677
All of the strings share same structure and the rule that I need to implement is, extract what's in between 5th and 6th occurrence of - (dash). In this particular case this is M.
How do I do that?
This would help you. The first capturing group will be the value between fifth and sixth dash:
https://regex101.com/r/UlQBqy/2
const re = /^(?:[^-]*-){5}(.*?)(?=-)/
console.log("Apparel-DTG-Tshirt-District-DT6000-M-Black-Mens-CF-20200304113232677".match(re)[1])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a requirement to allow any digits with only one character (either w or d or W or D) at a time with no sequence.
For example: 2 or 2w or 222W or 2d or 222D
(not like 2wd, 55dw, 2w5d, 2w5w, 2D5D etc)
Could you please provide solution on this. Thanks.
Try the following:
^\d+[wdWD]?$
Try it out:https://regex101.com/r/sYqjTi/1
If you don't want it to match just 2, remove the ?, it will make the last letter required.
This regex should work both on Java and JavaScript.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a problem in some substitution in javascript (HTML).
I need to substitute ONLY the tags around every number, e.g.
<1>
become:
<sub>1</sub>
or
<20>
become
<sub>20</sub>
etc.
How can I do?
Thank you so much!
You can use replace and regex with groups to achieve this:
var text = '<1>blabla<20>';
var newText = text.replace(/<(\d+)>/g, '<sub>$1</sub>');
console.log(newText);
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 8 years ago.
Improve this question
I just wanted to know difference between (/\s{2,}/) and (/\s{2,''}/) regular expressions?
Please explain with an example.
Are \s{2,} and \s{2,''} the same?
NO, both are different.
\s{2,} --> Two or more spaces.
\s{2,''} --> Matches a white space character[\r\n\t\f] and literal {2,''}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need to replace all word in except one word. the first word that contains "Thewo"
How can i do this with a RegEx?
Input String "We need to remove something from and keep a word Theword and save only first word Thewood Theworld"
Expted exsult: Theword
This will do what you want:
input.match(/\w*Thewo\w*/)
Since you are asking for the first word that contains "Thewo", I assume that "Thewo" can appear in the middle of a word. For example, it will match notTheworker in "and notTheworker here".