How to delete text before a numberHello, I've attached my .jmp file that I'm working with it.
I have a column with a variety of descriptions. In it, you will notice that most of them have "Qty #" in which the # could be any value. What I'm trying to do is either delete "Qty #" and everything before that for all of the rows, or just simply split off all of the characters after "Qty #" into its own column. I've been trying to figure this out for an hour and have not been successful. Here's some examples on what I'm trying to do:
Old Column
ELECTRICAL-EA Qty 1 KIT,VARIOUS,,STATOR WINDING REPAIR
New Column (trying to achieve this)
KIT,VARIOUS,,STATOR WINDING REPAIR
Old Column
FITTINGS-EA Qty 1 EDUCTOR,BRZ,4.000 X 4.000 X 2.500,STATIO
New Column (trying to achieve this)
EDUCTOR,BRZ,4.000 X 4.000 X 2.500,STATIO
Any help is much appreciated!
Re: How to delete text before a numberOops misread your request:
t0 = Contains( :Column 1, "Qty" );
t1 = Contains( Substr( :Column 1, t0 + 4 ), " " );
If( t0 > 0,
Substr( :Column 1, t0 + t1 + 4 ),
:Column 1
);
Re: How to delete text before a numberThere are multiple formulas to do this this is. Try this column formula:
Num( Regex( :Column 1, "Qty\s*(\d*)", "\1" ) )
Regular expressions cane be confusing, so here is an alternative column function. Words(str) breaks up strings; since no delimiter is specified, it breaks them up by spaces (white space). If qty is found the next word should be the value.
t0 = Contains( Words( Lowercase( :Column 1 ) ), "qty" );
If( t0 > 0,
Num( Words( :Column 1 )[t0 + 1] )
);