html « Regular Expression « Javascript Data Type Q&A

Home
Javascript Data Type Q&A
1.Array
2.Clojure
3.date
4.decimal
5.function
6.global
7.loop
8.math
9.number
10.object
11.Regular Expression
12.scope
13.String
14.Var
15.variable
Javascript Data Type Q&A » Regular Expression » html 

1. How to match with javascript and regex?    stackoverflow.com

I have the following HTML:

<span id="UnitCost5">$3,079.95 to $3,479.95</span>
And i want to use Javascript and Regex to get all number matches. So i want my script function to return: 3,079.95 AND 3,479.95 Note the ...

2. Matching strings containing HTML with javascript    stackoverflow.com

I am in a situation where I need to match two strings containing HTML.I I can not use exact comparison as the two stings may differ sometimes due to white spaces ...

3. Replacing   from javascript dom text node    stackoverflow.com

I am processing xhtml using javascript. I am getting the text content for a div node by concatenating the nodeValue of all child nodes where nodeType == Node.TEXT_NODE. The resulting string sometimes ...

4. Regular expression that ignores HTML entities    stackoverflow.com

I need a regular expression in javascript which does the following. Those instances of a which are not the part of an HTML entity, should be replaced with w. ...

5. regular expression to match specific text not linked    stackoverflow.com

I would like to write a regular expression in javascript to match specific text, only when it is not part of an html link, i.e.

match <a href="/link/page1">match text</a>
would not be matched, ...

6. Regular expression in javascript for restricting HTML entites like <    stackoverflow.com

Hii, I want to restrict the html entities like '&lt;' , "&gt;" , "&amp;"etc but it should accept '<' and '>' when i click on a button from the javascript. Can anybody gives ...

7. Non-terminating RegExp.exec in Rhino    stackoverflow.com

I have the following JavaScript program saved in a file pre.js:

var pre = readFile("method-help.html");
RegExp.multiline = true;
print(/<pre>((?:.|\s)+)<\/pre>/.exec(pre)[1]);
The contents of method-help.html is simply the page at http://api.stackoverflow.com/1.0/help/method?method=answers/%7bid%7d. What I'm trying ...

8. Matching multiple input values in regex    stackoverflow.com

I have the following input values and I was hoping someone could kindly tell me the best way to match all of the "values" (217, 218, 219) -- The html is ...

9. What's the problem with my script?    stackoverflow.com

Why is this giving me null?

<script language="javascript">
    var element     = "11";
    var string      = "7,11";
  ...

10. Transform text menu to HTML links in JavaScript    stackoverflow.com

I'm transforming a text only menu / command structure into HTML links in JavaScript. The text spans that I receive are of the form:

<span>1. First option     ...

11. Use JavaScript regex to replace numerical HTML entities with their actual characters    stackoverflow.com

I'm trying to use JavaScript & regex to replace numerical HTML entities with their actual Unicode characters, e.g.

foo&#39;s bar
?
foo's bar
This is what I got so far:
"foo&#39;s bar".replace(/&#([^\s]*);/g, "$1"); // "foo39s bar"
All ...

12. RegEx to replace html entities    stackoverflow.com

all. I'm looking for a way to replace the bullet character in Greasemonkey. I assume a Regular Expression will do the trick, but I'm not as well-versed in it as many ...

13. Javascript regular expression question    stackoverflow.com

I'm using javascript regex to do the following: I have the html content of a page saved inside a string, and I want to match all URLs on the page. For example, if ...

14. Problems With JavaScript And Regular Expressions    stackoverflow.com

I'm trying to get the YouTube link and get just it's Id(which is working nice). I'm trying to make a function to detect if the text entered is a URL or ...

15. Regex Not working    stackoverflow.com

I got this regex expression from REGEXlib and basically it checks to see if it is a valid UK DVLA Number Plate however i cannot get it to work within JavaScript ...

16. regex in javascript - variable inside regex    stackoverflow.com

Basically i want to return an error if the value of a field is non-numeric or less than a defined minimum length (from array). i'm struggling to get this javascript to ...

17. Javascript regular expression for creating HTML list    stackoverflow.com

I have to create html list from this code

- ali
- hammad
- shah
-- haripur hazara
-- gaga goo
- naqvi
The '-' represents starting of a list and nested list elements have extra '-' symbol ...

18. Regular expression for W3C compliant URLs?    stackoverflow.com

I'm trying to find a regular expression for a URL that will be compliant with the W3C standard for the HTML5 "url" input type (to be used in JavaScript). See

19. Regular Express issue - javascript    stackoverflow.com

I am trying to replace a text in javascript using a regular expression like following [example of what I am trying to do]:

<html><head></head>
<body>
  <div id="div1"><a href="#" title="This is Old">This is ...

20. Skip preceding html entities in javascript regex    stackoverflow.com

I'm using regex snippets to parse smileys into images, and encountering problems with the semicolon. For example, a smiley like ;) turns into a WINK icon, matching against

/;-?\)/g
and works ...

21. Get javascript code from html file    stackoverflow.com

I am trying to get the javascript code from an html file using C# and regular expressions. The code I use now is the following:

string js = Regex.Replace(code, @"^.*?\<script\s?.*?\>((.|\r\n)+?)\<\/script\>.*$", "$1", RegexOptions.Multiline);
But when ...

22. In JS, how do I determine if a string is contained within another string?    stackoverflow.com

In Javascript, how do I determine if some specific HTML is contained within a larger hunk of HTML? I tried regex:

var htmlstr;
var reg = /<b class="fl_r">Example</b>/.test(htmlstr);
but it doesn't work! Console outputs "missing ...

23. html tidy and javascript regular expressions    stackoverflow.com

When HTML Tidy see this HTML:

<script type="text/javascript">
    var left =  /</g
</script>
It generates
<script type="text/javascript">
    var left =  /<\/g
</script>
which causes the run-time error: unterminated regular ...

24. How to create URL links from strings    stackoverflow.com

I'm using:

var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1' target='internet'>$1</a>"); 
to turn, for example http://www.xxx.com into a clickable link. This works well! Does anyone know how to expand this expression to capture also www.xxx.com ...

25. Need Regex for HTML in javascript    stackoverflow.com

I am facing a problem regarding HTML Regex. My Problem is that I am working on a HTML part and i need only those tag which contains some inner text and i ...

26. JavaScript RegExp match text ignoring HTML    stackoverflow.com

Is it possible to match "the dog is really really fat" in "The <strong>dog</strong> is really <em>really</em> fat!" and add "<span class="highlight">WHAT WAS MATCHED</span>" around it? I don't mean this specifically, but ...

27. I don't understand why string.replace correctly executes function containing a variable?    stackoverflow.com

At the moment I'm reading a new HTML5 book (HTML5. Webseiten innovativ und zukunftssicher by Peter Kröner). There are some examples how to teach IE6-8 to understand HTML5. One strategy looks ...

28. Javascript regex to match string but only show text    stackoverflow.com

I have an HTML element with a title inside, like this. <details>Name of page</details> How can I make a regex to search for the <details> element, but only returning the text inside, ...

29. Regular expression for year sequence    stackoverflow.com

So I'm trying to match something like

2011,2012,2013
or
2011,
or
2011 
but NOT: 2011,201 or 2011,201,2012 I tried with ([0-9]{4},?([0-9]{4},?)*) but if the first year is matched, it does not consider the rest .

30. javascript regex replace html    stackoverflow.com

see - > i have the following text in a variable

var s = 

    "<html>
  <head>
    <style type="text/css" >     
 ...

32. Regex and HTML    sitepoint.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.