It is currently April 16th, 2024, 8:58 am



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Is regex order changeable?
PostPosted: November 26th, 2015, 9:42 pm 

Joined: May 17th, 2015, 10:35 am
Posts: 216
Hello,

since I use loads of regex to customize my postings and often rework them I just have to ask: is there a simple way to reorder them? Right now I'm working around this problem defining dummy sites where I copy my replacements to in the right order, delete all on the productive site and copy back all from the dummy. Quite some work, I wish it could be simpler. :-)

Wurstmu


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: November 27th, 2015, 4:21 am 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12639
Location: Earth
Hi,

no easy way (just by deleting / re-adding), but might make something for future later to change it.

I could only suggest to try having replacements which doesn't matter in which order they are applied.

Most popular replacements usually don't matter in which order they are applied.

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: November 27th, 2015, 10:51 am 

Joined: May 17th, 2015, 10:35 am
Posts: 216
I already try to plan the regexes in a way that makes maintaining and reworking comparingly easy - but sometimes it's the case you need a change you couldn't foresee and therefore a change of a part that gets already changed by another expression is necessary.

The other point is that maintaining an order means the regex list gets more human-readable that way. If I return to rework (or debug) the scheme it's far more easy to see how the single rows might depend on each other after the change. That was the problem just yesterday: I used something as an "anchor" for my regex that got changed by another entry and therefore my whole new expression didn't work out - I just didn't realize there were dependencies at first glance.

Maybe reordering isn't really necessary, but a second way of editing / importing them to TP would be really nice - are you familiar with sed? It allows to state multiple statements in some sort of script file. An example for sanitizing filenames:

Quote:
s/[[:space:]]/./g
s/Ä/Ae/g
s/ä/ae/g
s/Ö/Oe/g
s/ö/oe/g
s/Ü/ue/g
s/ü/ue/g
s/ß/ss/g

This would be a nice way to hand over rules for Java regex to TP also.

If I could import a set of rules with a single textfile or copy / paste such a list to get parsed and added to the regex list it would be a real life saver. Row syntax could be maybe

Code:
{{name}}{{searchstring}}{{replacestring}}r|n

Order could be easily changed then ;-) Would you accept this as a valid suggestion?

Wurstmu


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: November 27th, 2015, 11:15 am 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12639
Location: Earth
I know what sed is, not really using it, but I understand what you mean.

Might add importing from text file, but probably not too soon.

Most people don't even use regex replacements or replacements which would depend on each other.

You might want to look if you can merge some replacements to make it do the final result without depending on each other (so that the order won't matter).

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: November 27th, 2015, 1:57 pm 

Joined: May 17th, 2015, 10:35 am
Posts: 216
Freddy wrote:
I know what sed is, not really using it, but I understand what you mean.

Well, Java regex is somewhat more sophisticated anyway - the lookahead constructs alone make handling complex expressions a lot easier than with "traditional" or even POSIX regex.

Quote:
Might add importing from text file, but probably not too soon.

If and when you do it, please consider adding such lists via GUI also.

Quote:
Most people don't even use regex replacements or replacements which would depend on each other.

Most people don't even realize how powerful you made TP by implementing them or even what REs are. Next problem is there aren't many tutorials about Java regex ob the web - the examples in the TP FAQ are a good start, but don't really show the amazing capabilities.

I am really interested in developing awareness of that functionality and I think about aiding regex usage here in the forum for quite a long time. If you don't mind I will share my links and samples with the users in a thread apart from the existing regex problems topic. I would be happy if you take it as an approach to give something back for the great support you do here, mostly all alone it appears.

TP has some big advantages compared to other tools - I wish I could convince more users to switch. For many managing site-dependent customizations is important and being able to crawl a) sites for existing posts with same content and b) metadata concerning the content. Well, b) can be handled by other tools, that means customization management and searching for existent topics will attract the most potential customers.

Quote:
You might want to look if you can merge some replacements to make it do the final result without depending on each other (so that the order won't matter).

I have already consolidated a lot of my expressions over the last days, average count shrunk from 12 to 7 per site, but complexity has wildly increased - well, it was great fun figuring all these out. :-)

Wurstmu


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: November 28th, 2015, 12:44 am 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12639
Location: Earth
Maybe just PM me that extra information / links which you have. I can add them in the FAQ if you don't mind.

I redirect people to the FAQ a lot and that's probably the best place for them to find that information.

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: December 8th, 2015, 1:34 pm 

Joined: May 17th, 2015, 10:35 am
Posts: 216
Done!

Hope it'll help more users dealing with the topic and recognizing the power behind its concepts.

Note: example 3 from the topic is by far the most important. Explaining it a bit further (the (?mis)-part especially) will surely help newbies a lot!

I also saw you reworked the the FAQ over the last months, structure has been improved nicely - I really appreciate you also take your time to maintain the documentation.

Wurstmu


Top
 Profile  
Reply with quote  
 Post subject: Re: Is regex order changeable?
PostPosted: December 12th, 2015, 1:52 pm 
Site Admin
User avatar

Joined: March 10th, 2011, 11:14 pm
Posts: 12639
Location: Earth
Added in: http://poster.freddy.lt/faq.php?expand=faq204

_________________
themaPoster | themaCreator | themaManager | themaLeecher | themaRegister


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Theme designed by stylerbb.net © 2008
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All times are UTC