jquery - Text parsing and formatting with JavaScript -


I am working in an application where I face problems while formatting text (bold, italic, and underlined) Have to do I'm creating an array by dividing the entire text with # b #, # i # and # u # but for some scenarios this is difficult to divide. I have another situation where I have to separate the words like '%%' as well. Some examples are:

  1% # # # # # # # # # # # # # # # # # # # # # # # # # # In all cases, I need an array like the following -  
  [" A "," ","  Sample , "", with "%% text  b & gt; with & lt; / b & gt; With; %% "," ", & lt; B & gt; Text format & lt; / b & gt; "] [" %% & lt; B & gt; A & lt; / B & gt; %% "," | "," %% & lt; B & gt; B & lt; / B & gt; %% "," "," will be good. "] // space is excluded    

  var s =" a # i # sample # / i # %% text # b #% text format # b # ", s1 =" %% #b # a #b /% #% | It would be nice to %% #b #b #b #b / b # %% "; s.replace (/ # (. *?) # / g," <$ 1> "); //" A & lt; I & gt; Sample & lt; / I & gt; %% text & lt; B & gt; With %% text format & lt; / b & gt; "s1.replace (/#(.*?)#/g," & lt; $ 1 & gt; "); //" %% & lt; B & gt; A & lt; / B & gt; %% | %% & lt; B & gt; B & lt; / B & gt; %% would be nice. "  

You can enter with and & gt; You can use the capture group to change.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -