I have a content like this.  &lt;strong&gt;Citation1:&lt;/strong&gt; Firs&lt;b style="font-weight:bold"&gt;t&lt;/b&gt; Ci&lt;b style="font-weight:bold"&gt;t&lt;/b&gt;a&lt;b style="font-weight:bold"&gt;t&lt;/b&gt;ion   I want to remove all &lt;b&gt; tag using regex I am using below but its not working with multiple b tag.  function removeBoldString(str) {     const re = new RegExp('(&lt;b(.*)"&gt;)|(&lt;/b&gt;)', 'g');     return str.replace(re, ''); }
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
13425
I'm trying to write a blog post which includes a code segment inside a &lt;pre&gt; tag. The code segment includes a generic type and uses &lt;&gt; to define that type. This is what the segment looks like:  &lt;pre&gt;     PrimeCalc calc = new PrimeCalc();     Func&lt;int, int&gt; del = calc.GetNextPrime; &lt;/pre&gt;   The resulting HTML removes the &lt;&gt; and ends up like this:  PrimeCalc calc = new PrimeCalc(); Func del = calc.GetNextPrime;   How do I escape the &lt;&gt; so they show up in the HTML?
107897
I've been battling the following two questions for more than a day today.  Write a regular expression (comprised of {a, b}) that contain at least two b and do not contain abb. Write a regular expression (comprised of {a, b}) that contain abba and do not contain baa.  For the first part I wrote a basic one to start off with that doesn't handle the must two-b: b* OR a* OR (a+ AND b)* OR a*  I ran a few &quot;truth tables&quot; inputs over it and it seems ok. But the moment I add the requirement, things go haywire. Mostly because when pushing in those &quot;b&quot;s, you can suddenly use the OR to break things up. Same thing on the second one.... Any help would be greatly appreciated! Norah
111242
I have a , and I'm trying to match it to a regular expression to pull out some groups. The problem I'm having is that the URL can either end or continue with a "/" and more URL text. I'd like to match URLs like this:        But not match something like this:      So, I thought my best bet was something like this:    /(.+)/(\d{4}-\d{2}-\d{2})-(\d+)[/$]   where the character class at the end contained either the "/" or the end-of-line. The character class doesn't seem to be happy with the "$" in there though. How can I best discriminate between these URLs while still pulling back the correct groups?
20352
Is it possible to detect a valid regular expression with another regular expression?  If so please give example code below.
102991
I have a large text template which needs tokenized sections replaced by other text. The tokens look something like this: ##USERNAME##.  My first instinct is just to use String.Replace(), but is there a better, more efficient way or is Replace() already optimized for this?
57994
I've got data in SQL Server 2005 that contains HTML tags and I'd like to strip all that out, leaving just the text between the tags. Ideally also replacing things like &amp;lt; with &lt;, etc. Is there an easy way to do this or has someone already got some sample T-SQL code? I don't have the ability to add extended stored procs and the like, so would prefer a pure T-SQL approach (preferably one backwards compatible with SQL 2000). I just want to retrieve the data with stripped out HTML, not update it, so ideally it would be written as a user-defined function, to make for easy reuse. So for example converting this: &lt;B&gt;Some useful text&lt;/B&gt;&amp;nbsp; &lt;A onclick=&quot;return openInfo(this)&quot;    href=&quot;http://there.com/3ce984e88d0531bac5349&quot;    target=globalhelp&gt;    &lt;IMG title=&quot;Source Description&quot; height=15 alt=&quot;Source Description&quot;          src=&quot;/ri/new_info.gif&quot; width=15 align=top border=0&gt; &lt;/A&gt;&amp;gt;&amp;nbsp;&lt;b&gt;more text&lt;/b&gt;&lt;/TD&gt;&lt;/TR&gt;  to this: Some useful text &gt; more text
25338
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount% with a value pulled from a database. The problem is the capitalization of FirstName varies. That prevents me from using the String.Replace() method. I've seen web pages on the subject that suggest  Regex.Replace(strInput, strToken, strReplaceWith, RegexOptions.IgnoreCase);   However for some reason when I try and replace %PolicyAmount% with $0, the replacement never takes place. I assume that it has something to do with the dollar sign being a reserved character in regex.   Is there another method I can use that doesn't involve sanitizing the input to deal with regex special characters?
61489
I am looking for a regex statement that will let me extract the HTML content from just between the body tags from a XHTML document.  The XHTML that I need to parse will be very simple files, I do not have to worry about JavaScript content or &lt;![CDATA[ tags, for example.  Below is the expected structure of the HTML file is that I have to parse. Since I know exactly all of the content of the HTML files that I am going to have to work with, this HTML snippet pretty much covers my entire use case. If I can get a regex to extract the body of this example, I'll be happy.  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;   &lt;head&gt;     &lt;title&gt;     &lt;/title&gt;   &lt;/head&gt;   &lt;body contenteditable="true"&gt;     &lt;p&gt;       Example paragraph content     &lt;/p&gt;     &lt;p&gt;       &amp;nbsp;     &lt;/p&gt;     &lt;p&gt;       &lt;br /&gt;       &amp;nbsp;     &lt;/p&gt;     &lt;h1&gt;Header 1&lt;/h1&gt;   &lt;/body&gt; &lt;/html&gt;   Conceptually, I've been trying to build a regex string that matches everything BUT the inner body content. With this, I would use the C# Regex.Split() method to obtain the body content. I thought this regex:  ((.|\n)*&lt;body (.)*&gt;)|((&lt;/body&gt;(*|\n)*)   ...would do the trick, but it doesn't seem to work at all with my test content in RegexBuddy.
66832
Given the below XML snippet I need to get a list of name/value pairs for each child under DataElements. XPath or an XML parser cannot be used for reasons beyond my control so I am using regex.  &lt;?xml version="1.0"?&gt; &lt;StandardDataObject xmlns="myns"&gt;   &lt;DataElements&gt;     &lt;EmpStatus&gt;2.0&lt;/EmpStatus&gt;     &lt;Expenditure&gt;95465.00&lt;/Expenditure&gt;     &lt;StaffType&gt;11.A&lt;/StaffType&gt;     &lt;Industry&gt;13&lt;/Industry&gt;   &lt;/DataElements&gt;   &lt;InteractionElements&gt;     &lt;TargetCenter&gt;92f4-MPA&lt;/TargetCenter&gt;     &lt;Trace&gt;7.19879&lt;/Trace&gt;   &lt;/InteractionElements&gt; &lt;/StandardDataObject&gt;   The output I need is:      [{EmpStatus:2.0},  {Expenditure:95465.00}, {StaffType:11.A}, {Industry:13}]    The tag names under DataElements are dynamic and so cannot be expressed literally in the regex. The tag names TargetCenter and Trace are static and could be in the regex but if there is a way to avoid hardcoding that would be preferable.   "&lt;([A-Za-z0-9]+?)&gt;([A-Za-z0-9.]*?)&lt;/"   This is the regex I have constructed and it has the problem that it erroneously includes {Trace:719879} in the results.  Relying on new-lines within the XML or any other apparent formatting is not an option.  Below is an approximation of the Java code I am using:  private static final Pattern PATTERN_1 = Pattern.compile(..REGEX..); private List&lt;DataElement&gt; listDataElements(CharSequence cs) {     List&lt;DataElement&gt; list = new ArrayList&lt;DataElement&gt;();     Matcher matcher = PATTERN_1.matcher(cs);     while (matcher.find()) {         list.add(new DataElement(matcher.group(1), matcher.group(2)));     }     return list; }   How can I change my regex to only include data elements and ignore the rest?
13613
When I try to use multiple , the message box text is the concatenated text of all the tags, as if it is one tag.        In this case the correct form could be the next:     The 'a', 'the', 'or', 'on' tags are not allowed.
89840
The full html setting is only allowing certain tags to go through. How do I turn this off and allow all tags?     Full HTML   Allowed HTML tags: &lt;a&gt; &lt;blockquote&gt; &lt;br&gt; &lt;cite&gt; &lt;code&gt; &lt;dd&gt; &lt;div&gt; &lt;dl&gt; &lt;dt&gt; &lt;em&gt; &lt;li&gt; &lt;ol&gt; &lt;p&gt; &lt;span&gt; &lt;strong&gt; &lt;ul&gt;
15376
Have a look at   One of the bolds works, and the other one just turns up as ** in the actual post.  This is the string that isn't working: **x**ml n**ib**  Which renders as: xml nib
4355
For example, this regex  (.*)&lt;FooBar&gt;   will match:  abcde&lt;FooBar&gt;   But how do I get it to match across multiple lines?  abcde fghij&lt;FooBar&gt;
19883
How do I get the substring " It's big \"problem  " using a regular expression?  s = ' function(){  return " It\'s big \"problem  ";  }';
80302
&lt;div id="myDiv"&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt; &lt;/div&gt;   If you wanted to select the 2nd, 3rd and 4th a tags in the above example, how would you do that? The only thing I can think of is:  $("#myDiv a:eq(1), #myDiv a:eq(2), #myDiv a:eq(3)")   But that doesn't look to be very efficient or pretty. I guess you could also select ALL the as and then do run .each over them, but that could get very inefficient if there were a lot more as.
63162
Let's say:  &lt;div&gt;   pre text   &lt;div class="remove-just-this"&gt;     &lt;p&gt;child foo&lt;/p&gt;     &lt;p&gt;child bar&lt;/p&gt;     nested text   &lt;/div&gt;   post text &lt;/div&gt;   to this:  &lt;div&gt;   pre text   &lt;p&gt;child foo&lt;/p&gt;   &lt;p&gt;child bar&lt;/p&gt;   nested text   post text &lt;/div&gt;   I've been figuring out using Mootools, jQuery and even (raw) JavaScript, but couldn't get the idea how to do this.