RegExReplace optimisation Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

RegExReplace optimisation

10 Jun 2018, 02:23

hi :wave:

In my list the lines are shortened and should still be understandable for humans.
Example of the line (other examples https://regex101.com/r/GQjPg0/3 :
Recent|r|C:\Users\bla\AppData\Roaming\Microsoft\Windows\Recent
will only
Recent :thumbup:
displayed.

That's great. :thumbup:

But if one line contains e.g.
Simple
will only
Sim :thumbdown:
displayed.
This is stupid. Simple alone would be understandable enough.

i use this regex:
^[_]*([^|\n]+)[^\.\n]*?([^|\n]{3,})$

and i test / develop it here:
https://regex101.com/r/GQjPg0/3
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: RegExReplace optimisation

10 Jun 2018, 05:14

Provide more details. Do you want only first word to be displayed, part of the sentence (up to X symbols) or entire sentence till | symbol?
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: RegExReplace optimisation

10 Jun 2018, 08:31

SirRFI wrote:Provide more details. Do you want only first word to be displayed, part of the sentence (up to X symbols) or entire sentence till | symbol?
thanks. a simple ? at the end did the job.

the green area is the visible part for the user.
the blue is metainformation for the script.
the red is what executed from the script (if there is now red and now blue part script set in the green part).

i use it i my github IntelliSense script.

BTW in the regex before also the file extension .ahk was cut of. its also ok i think to have it with extension. its also good readable with extension.
Attachments
2018-06-10 15_29_23-Online regex tester and debugger_ PHP, PCRE, Python, Golang and JavaScript.png
2018-06-10 15_29_23-Online regex tester and debugger_ PHP, PCRE, Python, Golang and JavaScript.png (25.92 KiB) Viewed 1714 times
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: RegExReplace optimisation

10 Jun 2018, 09:24

How about this?:
^[_]*([^|\n\r]+)(\|[^\.\n]+\|)?([^|\n\r]+)?$
https://regex101.com/r/GQjPg0/5
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: RegExReplace optimisation  Topic is solved

10 Jun 2018, 10:51

SirRFI wrote:How about this?:
^[_]*([^|\n\r]+)(\|[^\.\n]+\|)?([^|\n\r]+)?$
https://regex101.com/r/GQjPg0/5
yes looks good :)

alle these follwong works nearly same. so i dont know which to prefer.
^[_]*([^|\n\r]+)(\|[^\.\n]+\|)?([^|\n\r]+)?$
^[_]*([^|\n]+)[^\.\n]*?([^|\n\r]+)?$
^[_]*([^|\n\r]+)[^\.\n]*?([^|\n\r]+)?$


first i tryid yours seems works not (see screenshot). do i something wrong?
maybe a server issue.
Attachments
2018-06-10 17_50_27-Online regex tester and debugger_ PHP, PCRE, Python, Golang and JavaScript.png
2018-06-10 17_50_27-Online regex tester and debugger_ PHP, PCRE, Python, Golang and JavaScript.png (25.29 KiB) Viewed 1683 times
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: RegExReplace optimisation

10 Jun 2018, 12:06

Untested in AHK though, but should behave the same.
Attachments
Screenshot-2018-6-10 Online regex tester and debugger PHP, PCRE, Python, Golang and JavaScript.png
Screenshot-2018-6-10 Online regex tester and debugger PHP, PCRE, Python, Golang and JavaScript.png (20.51 KiB) Viewed 1394 times
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: RegExReplace optimisation

11 Jun 2018, 07:27

SirRFI wrote:Untested in AHK though, but should behave the same.
sorry SirRFI yes yours work :thumbup: thats i already tried to say here:
SL5 wrote:...
first i tryid yours seems works not (see screenshot). do i something wrong?
maybe a server issue.
it was probably a server issue of the regex website :think:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Descolada, Google [Bot], Oblomov228 and 174 guests