javascript - Finding the first sentence with jQuery -


I'm trying to find the first sentence of a textarea. Right now, I can find the full stop before and can convert it to an array with .split () , but what happens if they use exclamation marks, question marks, etc. ?

I have the following:

  var l = $ ('p'); $ ('Texture') keyboard (function () {var t = $ ('textarea'). Val (); var t = t.split ('.'); L.text (t [0]);}) ;   

Is there any way to make it more fully, so it is divided into any form:

. , . , ! , ? , enter / linebreak

Any help would be great,

Yes there is a way.

Do this:

  var t = t.split (/ [\ ?! \. \ n \ r \] /);   

I am using regex , in which I am using the character square to define how to split.

Comments

Post a Comment

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -