Tuesday, 15 June 2010

grep - Pulling out lines which contain certain words exactly once -


I am trying to draw a line in a tab delimited text file that contains all user-specified words correctly once (Does the sequence 'does not matter).

For example, I need to find the line that includes' ca_ ',' cs_ ',' xvi '' and 'js_' properly once.

Enter image details here

Do I have to grep Can i use

Is there a possible solution? Are you trying to do this?

  var rawString = 'CA_1234567 CA_R345335 CS_I 8788765 CA_3456783 CS_0986887 CS_scaffolding2 CA_scaffolding3'; Var valArr = rawString.split (''); // Note: In the actual code, CA, CA, etc., put in an array and runs again CAItems = $ .grep (valArr, function (val) {if (val.startsWith ('CA')) {return val ;}}); Var CSItems = $ .grep (valArr, function (val) {if (val.startsWith ('CS')) {return val;}}); $ ('# CAValuesTxt') Text (CAItems.join ('')) $ ('# CSValuesTxt'). Text (CSItems.join ('')) String.prototype.startsWith = function (prefix) {Return IndexOf (prefix) === 0; }  
  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/JQuery/1.11.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Label & gt; Values ​​starting with CA: & lt; / Labels & gt; & Lt; Label id = 'CAValuesTxt' & gt; & Lt; / Labels & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Label & gt; Values ​​start with CS: & lt; / Label & gt; & Lt; Label id = 'CSValuesTxt' & gt; & Lt; / Label & gt;  

I hope it helps!


No comments:

Post a Comment