cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

Can implement this substitution with an operation with a regex?

For example, this file is a txt file.TAB spacing:
Column 2 contains, column 2 contains
The maximum number of rows is 5
Can you use regular substitution to replace rows with less than 5 such symbols to complete the cell with a total of 5 similar symbols?
Make up as shown in the figure.

2024-10-15_12-01-34.png

Thanks Experts!

13 REPLIES 13
lala
Level IX

Re: Can implement this substitution with an operation with a regular?

Of course, for ease of handling, the contents of column 1 can also be added according to this rule.

jthi
Super User

Re: Can implement this substitution with an operation with a regular?

I'm not really sure what we are trying to implement here based on your text and example provided. Could you expand on it a bit?

-Jarmo
lala
Level IX

Re: Can implement this substitution with an operation with a regular?

A	B	C
00001	744811604804487748	1
00002	744811604411447740~744811607410407768	1▲1
00003	744811607000017746~744811607407400440~744811607611467718~744811600601460016	1▲1▲1▲1
00004	744811606810447747	1
00005	744811606400167710~744811606610607767~744811608807400040~744811401407170047	1▲1▲1▲1
00006	744811607006017776~744811606014617747~744811600606400074	1▲1▲1
00007	744811607114067714~744811607406147747~744811607704147760~744811607710174146~744811600014600011	1▲1▲1▲1▲1
00008	744811604810187746~744811606706407717~744811606607400107	1▲1▲1
00009	744811608814480014~744811608704464148~744811401101140018~744811401607480040~744811401714140017	1▲1▲1▲1▲1
00010	744811606607177767~744811606707470064~744811608610440011~711741608004176007~744811401606180041~744811401704470014	1▲1▲1▲1▲1▲1
00011	744811607401167716~744811607408417748~711047607710460644~744811607711077714	1▲1▲1▲1
00012	460144607710400044~744811607711077716~744811400601440046~744811401104410044	1▲1▲1▲1
00013	744811607814617747~410144608807046447~744811608110140017~744811400807170010	1▲1▲1▲1
00014	744811607807117717~744811607806117747~744811608610400060~744811608804087740~744811400806070014	1▲1▲1▲1▲1
  • This effect is achieved after a regular substitution:

  • Thanks Experts!

2024-10-15_17-44-25.png

jthi
Super User

Re: Can implement this substitution with an operation with a regular?

Are we trying to add more ▲ to end of last column if there is less than five of them?

-Jarmo
lala
Level IX

Re: Can implement this substitution with an operation with a regular?

Yes, of course column 2 is treated by the same rules.

For convenience, you can first replace ~ with ▲

Thanks!

  • I want to do it in an alternate way, not in a tabular way.

txt="……";
tx=Substitute(txt,"~","▲");ccoyy

 

jthi
Super User

Re: Can implement this substitution with an operation with a regular?

Forcing yourself to use regex is in my opinion a bad idea. In this case you could for example loop line by line, replace ~ and triangles with "" on columns two and three, check how many were replaced and then add them to the end of correct "columns".

-Jarmo
lala
Level IX

Re: Can implement this substitution with an operation with a regular?

It seems that python's way of handling memory arrays is flexible and simple

2024-10-18_15-58-02.png

jthi
Super User

Re: Can implement this substitution with an operation with a regular?

Is there a reason why you couldn't do exactly (or almost) same thing in JSL? 

-Jarmo
lala
Level IX

Re: Can implement this substitution with an operation with a regular?

  • In JSL I don't know how to write simply in the form of memory arrays

  • Thanks Experts!

Recommended Articles