String Tools

Input/Result
Hold for a moment
Parameter
Actions
       
       
       
     
       
   

Examples

Insert / Trim

a.jpg                                           <img src='a.jpg                              <img src='a.jpg'/>
bb.png  -- insertAtBeginning("<img src='") -->  <img src='bb.png  -- insertAtEnd("'/>") -->  <img src='bb.png'/>
c.gif                                           <img src='c.gif                              <img src='c.gif'/>
⎵ ⎵ ⎵1⎵ ⎵                                  1⎵ ⎵                    1
⎵ ⎵ ⎵ ⎵ ⎵ ⎵2⎵ ⎵ -- trimAtBeginning() -->   2⎵ ⎵ -- trimAtEnd() --> 2
⎵3⎵ ⎵ ⎵                                    3⎵ ⎵ ⎵                  3

Delete

img-a.jpeg                                    a.jpeg                                 a.jp
img-b.jpeg  -- deleteAtBeginning("img-") -->  b.jpeg       -- deleteAtEnd("eg") -->  b.jp
xxx-c.jpeg                                    xxx-c.jpeg                             xxx-c.jp
img-a.jpeg                               a.jpeg                         a
img-b.jpeg  -- deleteAtBeginning(4) -->  b.jpeg  -- deleteAtEnd(4) -->  b
xxx-c.jpeg                               xxx-c.jpeg                     c    

Replace

Replace in every line (replace(p1,p2)) or over multiple lines (replaceAllText(p1,p2)).
1-clipboard.jpg                                       1-img.jpg                                                     1-img.jpg
2-clipboard.jpg                                       2-img.jpg                                                     2-img.jpg
3-clipboard.jpg                                       3-img.jpg                                                     3-img.jpg
                 -- replace("-clipboard","-img") -->              -- replaceAllText("img\nimg","clipboard") -->
img                                                   img                                                           clipboard                              
img                                                   img

4-clipboard.jpg                                       4-img.jpg                                                     4-img.jpg

Split

The;quick;brown;fox -- split(";") --> The
                                      quick
                                      brown
                                      fox
The;quick;brown;fox -- splitIncl(";") --> The;
                                          quick;
                                          brown;
                                          fox
With regular expression:
The;quick,brown.fox -- split("regexp:[;.,]") --> The
                                                 quick
                                                 brown
                                                 fox
001 line1 002 line2 003 line3 -- splitIncl("regexp:line[0-9]+ ") --> 001 line1
                                                                     002 line2
                                                                     003 line3

Match (regexp)

match(p1) transforms every line by the matched expression p1.
mega1234                          1234
666killer  -- match("[0-9]+") --> 666
ha000mmer                         000
OnlyText                                
matchAndReplace(p1,p2) tries to match the expression p1 and replace it with p2.
mega1234                                             megaNUMBER
666killer  -- matchAndReplace("[0-9]+","NUMBER") --> NUMBERkiller
ha000mmer                                            haNUMBERmmer
OnlyText                                             OnlyText
matchAndReplace(p1,p2) also allows to build groups and replace them
mega1234                                                             1234mega  
666killer  -- matchAndReplace("([a-z]*)([0-9]+)(a-z*)","$2$1$2") --> 666killer 
ha000mmer                                                            000hammer 
OnlyText                                                             OnlyText
Just replace every second occurance in a line
a a                                                                           a A  
a b a           -- matchAndReplace("(.*?)(a)(.*?)(a)(.*?)","$1$2$3A$5") -->   a b A 
a b b a c c c                                                                 a b b A c c c

Delete Matching Lines / Duplicates

The                                     The         The                                        brown
quick                                   quick       quick                                      fox
brown                                   jumps       brown                                      over
fox                                     the         fox                                        dog
jumps  -- deleteMatchingLines("o") -->  lazy        jumps  -- deleteNonMatchingLines("o") -->  
over                                                over
the                                                 the 
lazy                                                lazy
dog                                                 dog
aaa                             aaa
bbb                             bbb 
ccc   -- deleteDuplicates() --> ccc
bbb 
aaa 
ccc
With regular expression
The                                               quick       
quick                                             jumps       
brown                                             lazy
fox                                     
jumps  -- deleteMatchingLines("regexp:[oe]") -->  
over             
the              
lazy             
dog              

Sort

2                     1                      4
4   -- sortAsc() -->  2  --> sortDesc() -->  4
4                     4                      2
1                     4                      1

Advanced

In the parameter field you can put two prefix for a special commands

Insert line numbers

a                                              1 a
b  -- insertAtBeginning("eval:lineNr+' '") --> 2 b 
c                                              3 c              

Reverse Line

abc                                                                        cba
def  -- replace("eval:line","eval:line.split('').reverse().join('')") -->  fed
ghi                                                                        ihg

Delete every second line

a                                                a
b                                                c 
c  -- deleteMatchingLine("eval:lineNr%2==0") --> e 
d 
e

Delete empty lines

a                                     a
b                                     b 
                                      c  
c  -- replaceAllText("\n\n","\n") --> d
d                                     e 
                                      f
e
f

combine first and second line to one line

a                                                                                       ab
b                                                                                       cd 
c  -- insertAtEnd("eval: let res=''; if (lineNr%2==1) res='+++'; else res=''; res") --> ef
d     replaceAllText('+++\n',' ')  
e
f

Sort by the second word

Adam Riese                                                                                                   Tina Hübsch
Martha Schlau  -- sortAsc("eval:(a,b)=>{if(a.split(' ')[1]>b.split(' ')[1]) return 1; else return -1;}") --> Adam Riese
Tina Hübsch                                                                                                  Martha Schlau 

Replace a number with its number of stars

1                                                                                                *
2                                                                                                **
3                                                                                                ***
4 -- replace("eval:line","eval:let res='';for(let i=0;i<Number(line);i++) res=res+'*'; res") --> ****
3                                                                                                ***
2                                                                                                **
1                                                                                                *

Find information (info:) and put it in an other place (newPlace:) in the line

abc info:mySecret xxx newPlace: yyy                                                                  abc info: xxx newPlace:mySecret yyy
info:4911 xxx newPlace: what          -- matchAndReplace("(.*?)info:(.*?) (.*?)newPlace:(.*) ",  --> info: xxx newPlace:4911  what
xxx info:doit newPlace: now                              "$1info: $3newPlace:$2 $4")                 xxx info: newPlace:doit now