LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2014, 06:26 PM   #1
Mimouch
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Rep: Reputation: Disabled
A simple regex help


Hi;
I need to grab any the format ten numbers then a dot then jpg or png inside the {image}{/image} tag, for example :

1. {image}1390324469.jpg{/image} should return 1390324469.jpg
2. {image} 1390324469.jpg {/image} should return 1390324469.jpg
3. {image}unicode or non numners characters1390324469.jpgunicode or non numbers characters{/image} should return 1390324469.jpg

This one "#{image}(.*?){\/image}#i", does only work in the first case and doesn't work in the second and third cases. Thank you.
 
Old 01-23-2014, 01:20 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Which tool?
Here's a start using egrep
Code:
echo ' {image} 1390324469.jpg {/image} '|egrep -o '([0-9]+.jpg)'
1390324469.jpg
 
1 members found this post helpful.
Old 01-23-2014, 11:29 AM   #3
Mimouch
LQ Newbie
 
Registered: Dec 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi, i want it for php not bach, sorry.
 
Old 01-23-2014, 10:48 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Show us what you've done so far; we prefer to help, rather than just hand out answers.
Besides, I think we need to see examples of the 3rd case to really help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] simple regex question asherbarasher Linux - Newbie 16 05-20-2013 01:35 PM
[SOLVED] simple regex problem doughyi8u Programming 4 01-08-2012 08:55 PM
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 02:10 AM
[SOLVED] What's Wrong with the RegEx [Simple] thund3rstruck Programming 2 04-04-2011 12:04 PM
simple regex not so simple (perl) ludeKing Programming 5 03-02-2005 03:29 AM


All times are GMT -5. The time now is 01:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration