PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Mar 28, 2017 10:46 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 26, 2016 10:45 am 
Offline
Forum Newbie

Joined: Wed Oct 26, 2016 10:32 am
Posts: 1
hi there,

i have a basic knowledge of regex, but i came across a problem that exceeded my skills. i have a string like this:

Syntax: [ Download ] [ Hide ]
[AB] SomeText (26-10-2016)


and using regex i want to transform it to:

Syntax: [ Download ] [ Hide ]
[AB] 2016.10.26 - SomeText


is that possible? what regex command could i use for this?

greetz


Top
 Profile  
 
PostPosted: Wed Oct 26, 2016 12:30 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6379
Location: WA, USA
Regular expressions don't have "commands".

Match each portion of the string that you want to deal with, then put each into the substitution string wherever you want. For example, the search and replace could be
Code:
\[(..)\] (.*?) \((\d\d)-(\d\d)-(\d\d\d\d)\)

Code:
[\1] \5.\4.\3 - \2

The [AB] doesn't change so actually you could just ignore that part.


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 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

Jump to:  
Powered by phpBB® Forum Software © phpBB Group