tag « 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 » tag 

1. Trying to replace html tags using regex    stackoverflow.com

For the example, I'm trying to replace

<script type='text/javascript'>some stuff</script>
with:
<div type='text/javascript'>some stuff</div>
I'm currently testing with:
alert( o.replace( /(?:<\s*\/?\s*)(script)(?:\s*([^>]*)?\s*>)/gi ,'div') );
But what I'm getting is:
divsomestuffdiv
How can I get this to only replace the "script" ...

2. Regex replace string but not inside html tag    stackoverflow.com

I want to replace a string in HTML page using JavaScript but ignore it, if it is in an HTML tag, for example:

<a href="google.com">visit google search engine</a>
you can search on ...

3. How to get regex to match multiple script tags?    stackoverflow.com

I'm trying to return the contents of any tags in a body of text. I'm currently using the following expression, but it only captures the contents of the first ...

4. In JavaScript, how can I replace text in an HTML page without affecting the tags?    stackoverflow.com

I'm trying to figure out how to do a replace with Javascript. I'm looking at the entire body of the page and would like to replace the keyword matches NOT ...

5. popluating multiple id tags    stackoverflow.com

How can i populate multiple id tags simultaneously. On my page i have id tags starting with "total_" phrase, like total_1, total_2 etc., is there a way by which i can populate ...

6. Preserving SCRIPT tags (and more) in CKEditor    stackoverflow.com

Update: I'm thinking the solution to this problem is in CKEDITOR.config.protectedSource(), but my regular-expression experience is proving to be too juvenile to handle this issue. How would I go ...

7. Javascript Regex to replace URLs with links, but not in embed (or img) tags    stackoverflow.com

I'm currently using the following code, to search the a div on a page for URLs and replace them with a tags. However when we have a embed tags within the ...

8. Help write regex that will surround certain text with tags, only if the tag isn't present    stackoverflow.com

I have several posts on a website; all these posts are chat conversations of this type: AD: Hey!
BC: What's up?
AD: Nothing
BC: Okay They're marked up as simple paragraphs surrounded by <p> ...

9. JavaScript lazy regex for matching HTML tags    stackoverflow.com

I'm having a problem writing a regular expression for matching HTML tags. I found a similar entry here, but this didn't quite work in my case. Here's my test string: ...

10. How to replace all html tags from to \n\n [using regexp (JavaScript)]    stackoverflow.com

How to replace all HTML tags from <anything> to \n<anything> and </anything> to <anything>\n

var text = "<anything>welcome</anything><anything>Hello</anything>";
result
var text = "\n<anything>welcome</anything>\n\n<anything>Hello</anything>\n";
This code will help you (match all tags)
</?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?>

11. JavaScript Regular Expression not matching tags    stackoverflow.com

I am trying to match URLs with a tested Regex expression but when I use JavaScript to evaluate it returns false. Here is my code:

var $regex = new RegExp("<a\shref=\"(\#\d+|(https?|ftp):\/\/[-a-z0-9+&@#\/%?=~_|!:,.;\\(\\)]+)\"(\stitle=\"[^\"<>]+\")?\s?>|<\/a>");

var $test = new ...

12. Javascript REGEX : Tags    stackoverflow.com

I want to convert words into tags. So for example I have an input, if I type in in this apple, windows, stackoverflow, google, microsoft then I will get this: apple windows stackoverflow google microsoft Delimiters should be space, semicolon, ...

13. Javascript Regex: Get everything from inside / tags    stackoverflow.com

What I want


From the above subject I want to get search=adam and page=content and message=2. Subject:
/search=adam/page=content/message=2
What I have tried so far
(\/)+search+\=+(.*)\/ 
But this is not good because sometimes the subject ends with ...

14. Javascript RegExp with tagged expressions    stackoverflow.com

I would like to know if there is a way to perform replacement with regular expressions in JS using tagged expressions, like scintilla engine does (used in Notepad++, for example). For instance, ...

15. How do I detect a subset of tags with regexp in JavaScript?    stackoverflow.com

I want to detect, in a JavaScript String, if there are some tags except than a list that I have. It means if in my String there are undesirable tags, then ...

16. Regex: Removes all HTML Tags and returns just the text?    stackoverflow.com

i want to strip just text values from below html with js.

var Str = "<span style="">MY name is KERBEROS.</span><B>HELLO Everbody</B>"
All text strips with codes that is below;
[^<>]+(?=[<])
But i want to strip ...

17. Matching a string only if it is not in