how to make Regular expression into non-greedy ?

Posted by Rueta on Stack Overflow See other posts from Stack Overflow or by Rueta
Published on 2010-05-13T03:46:30Z Indexed on 2010/05/13 3:54 UTC
Read the original article Hit count: 278

Filed under:
|
|

Hi everyone!

I have made a Work with JQ. My Work is a string width a special character block begin and end of string. I want take the text in that special characters, i used regular expression for find in string, but how to make JQ find multi result when have two special character or more.

My html here;

<div id="container">
    <div id="textcontainer">
     Cu?c chi?n pháp lý gi?a [|co th?|nghi?m|] th? tru?ng [|test2|dây là test l?n 2|] ch?ng khoán [|M?|day la nuoc my|] và ngân hàng d?u tu quy?n l?c nh?t Ph? Wall m?i ch? b?t d?u.
 </div>
</div>

and my JQ

$(document).ready(function() {

 var takedata = $("#textcontainer").text();
 var test = 'abcd adddb';
 var filterdata = takedata.match(/(\[.+\])/);

 alert(filterdata); 

//end write js 
});

my result is: [|co th?|nghi?m|] th? tru?ng [|test2|dây là test l?n 2|] ch?ng khoán [|M?|day la nuoc my|] . but this is'nt the result i want :(. How to get [text] for times 1 and [demo] for times 2 ?. pls help me !. thankyou :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about filter