Solved

Regular Expression - only the first result

Posted on 2014-09-27
1
152 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now