Solved

Regular Expression - only the first result

Posted on 2014-09-27
1
155 Views
Last Modified: 2014-09-27
Hi E's, I have this code for select in textarea all the text between <b> and </b> html tags (the selection include the tags):
words: [{
            color: 'yellow',
            words: ['<b>[^"]*</b>']
        }, {

Open in new window

and the result is:the output of my codeThe problem is, when have in the same textarea more then one set of <b>...</b> html tags, the script will select the first <b> and the last </b>. For example, if I have this text in my textarea:
<b>something></b>bla bla bla<b>more bla</b>
, all text is selected.
What change I have to do in my regular expression '<b>[^"]*</b>', for just select the <b> and just the next </b> (not the last in textarea)?

The best regards, JC
0
Comment
Question by:Pedro Chagas
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40347656
<b>[^"]*?</b>

Open in new window

0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question