Skip to content Skip to sidebar Skip to footer

Break String Into Columns Using Regular Expression

I am new in regex, i want to break the give string into 6 parts using regular expression. I am using the Pentaho data integration tool (ETL tool) Given string: 1x 3.5 mL SST. 1x 4.

Solution 1:

The single string datum you've given looks like it should match the regex pattern:

(\d*)x\s(\d*\.\d*)\smL\s(.*)\.\s(\d*)x\s(\d*\.\d*)\smL\s(.*)\.

You can use it with Regex Evaluation step:

Regex Evaluation

Solution 2:

Use split function and regex \. | mL |x

var text = '1x 3.5 mL SST. 1x 4.0 mL gray cap cryovial'
arr = text.split(/\. | mL |x /g)

var tb = document.getElementById("table")
//creat rowvar tr = document.createElement("tr")

for (s of arr) {
  // create cellvar td = document.createElement("td")
  var txt = document.createTextNode(s);
  td.appendChild(txt)
  tr.appendChild(td)
}

tb.appendChild(tr);
<tableid='table'border="1"><tr><th>Par_Count</th><th>Par_Qty</th><th>Par_Tube</th><th>Child_Count</th><th>Child_Qty</th><th>Child_Tube</th></tr></table>

Post a Comment for "Break String Into Columns Using Regular Expression"