Javascript regular expression - match */ [closed] - 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 8 years ago.
Improve this question
I am trying to write a tool whereby you enter incorrectly formatted CSS into one text area, hit submit and it runs a few regular expressions and feeds back the minified and "maxified" CSS in 2 other textareas. First it removes all white space (that is, unless it is within a line - only white space at the end of a line and tabs within a line is removed). It then proceeds to fall over on the next line - reg = new RegExp("\*\/", "\g");. The error is Uncaught SyntaxError: Invalid regular expression: /*//: Nothing to repeat. I can't figure out why this is. Does anyone have any idea how to resolve this? Thanks in advance.

If you want */ use reg = /\*\//g; and if you want /* use reg = /\/\*/g;.

Related

RegEx: Matching HTML tags and text in a string of HTML [closed]

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 7 months ago.
This post was edited and submitted for review 7 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I have written a regular expression which matches all header HTML elements, including their text. The present regular expression I am using is: /<(h[1-6])[^>]*>(.*?)<\/\1>/gi.
I want to match all headings and text until testing-options appears in the string below:
<h1>jfhfnjkgf</h1><h2>fegsg</h2><h2>fwegrweghrw</h2><h4>sfadfsaf</h4><h4>ukfdsnsjkfsd</h4><ac:structured-macro ac:name="testing-options" ac:schema-version="1" data-layout="default" ac:local-id="8bbfe293-eeb9-4785-9873-9fb9b218692b" ac:macro-id="bed737bbfaaf5f1df5f68a0ecc0bc6a7"><ac:parameter ac:name="enable-testing">disable</ac:parameter></ac:structured-macro><h3>bkbkvwv</h3><h4>vbdkhvbkwv</h4><h3>v n vw bv</h3><p />
The final regex provided should match every heading and text until testing options appears in the string above. In this case, the match should be: <h1>jfhfnjkgf</h1><h2>fegsg</h2><h2>fwegrweghrw</h2><h4>sfadfsaf</h4><h4>ukfdsnsjkfsd</h4>.
Use the following Regex without global flag
(<h[1-6]>\w+<\/h[1-6]>)*

Regular expression (Regex) to allow only number or specific character with number at a time [closed]

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.

Replace string that contains dynamically numbers [closed]

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 variable that contains the string: attribute_value[XXX][] where XXX every time that page loads is a 3-digit number that changes every time.
How can i use .replace function in javascript to replace attribute_value[XXX][] with something specific regardless the XXX value?
Thank you in advance
You can use regular expression for that
str.replace(/attribute_value\d+/, 'aa');
here '\d' indicates digits and '+' indicates one or more occurances
str.replace(/attribute_value\d{3}/, 'aa');
Use this if you want to replace only first 3 digits

How to make textarea with tagging feature like in Youtube [closed]

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 7 years ago.
Improve this question
I want to create a textarea that behaves like the tagging box in Youtube. Specifically:
Allow you to type whatever you want
When you press space it turns the word you just typed into a tag
You can remove tags with backspace or by clicking x on tags
Show suggestions as you type
You can add tags from outside the textarea as well
Also, what exactly is this method called?
I just used a javascript library 2 days ago that does excatly this. Check out the TextExtJs library

Ignore line break in Indesign [closed]

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 7 years ago.
Improve this question
In my Indesign document having the text "This is Indesign \napplication"----here \n is the line break.
Then, I am find text in grep
find grep:This is Indesign application
The text cannot be selected. because, the sentence contain line breaks.
So, Please help me to select the sentence.
Thanks & regards by,
Annadurai.
Just an idea: try searching for whitespace between words. This can be done via regular expressions, either with grep or with javascript.
To do this, you have to search for "This\s+is\s+Indesign\s+application". Each "\s+" means: one or more whitespace characters (blanks, newlines, tabs). Code snippet for javascript:
string.search(/This\s+is\s+Indesign\s+application/);
If this does not help, you should provide more information of what you've done so far.

Categories

Resources