Sublime Forum

Regex: Change the sentence order randomly (by dot)

#1

hello. I want to change the sentence order randomly (by dot). For example:

1 My mother is home. 2 My father is at work. 3 My sister loves hot milk. 4 My lovely dog is here. 5 I go to mall. 6 She seen Jupiter. 7 I read a book. 8 I drove all night. 9 Book is here. 10 Many people want.

The output should be:

8 I drove all night. 5 I go to mall. 1 My mother is home. 7 I read a book. 2 My father is at work. 9 Book is here. 3 My sister loves hot milk. 10 Many people want. 4 My lovely dog is here. 6 She seen Jupiter.

I made a regex, but must be improved:

Find: (.*?\.)(.*?\.)(.*?\.)(.*)|($4$1)|$2$4

Replace by: $4$3$2$1$5

Can anyone help me?

0 Likes

#2

That’s not how regex works. It must be a plugin.

image
image

I am not sure whether this is a plugin but it just shows in my menu.

0 Likes

#3

must be a way !!

I need to modify 15 text simultaneous, cannot use this option for every text file. Need something faster. If SublimeText has this “Shuffle” option, then must be a regex or a python code. I need the regex, because I don’t know python :slight_smile:

0 Likes

#4

I have it as well (and I never noticed this sub menu). It’s using the permute_lines command in Default/sort.py, so it’s in every installation.

1 Like

#5

I find a very good explanation here. Take a look, just to see a super solution

0 Likes

#6

I won’t call it “random”.

image

2 Likes