Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Regexp - need a tweak...

Posted on 2008-11-20
2
Medium Priority
?
242 Views
Last Modified: 2012-05-05
Hi !
I have a blobdata in a MS SQL server containing the rubbish below:
@¬ýýýO_TRG_11ýýýýýýýýýØ
)ýýýýýýýýýýýýýýýýýýýýý\\trg4\eh_shared\input\78-268P02475923.tifýýýýýç ý¬ýýý*ý!ýÿý

I need to extract the string "78-268P02475923.tif" - and nothing else... so from the last \ until (and including) .tif

I need a PHP function that will return this - who can help me ??

RegEXP or anything goes :-)
0
Comment
Question by:trg_dk
2 Comments
 
LVL 11

Accepted Solution

by:
bansidhar earned 2000 total points
ID: 23002941
try the following. This will match files with 3 or 4 char extension like .tif or .tiff
$a=' @¬ ýýýO_TRG_11ýýýý ýýýýýØ) ýýýýýý ý ý ý ýýý ýýýýýýýýý\\trg4\eh_shared\input\78-268P02475923.tifý ýýýýç ý ¬ ý ý ý*ý! ýÿý';
if (preg_match_all('/\\\([a-zA-Z0-9-_]*\.[a-zA-Z0-9]{3,4})/',$a,$matches)){
	$required_match=$matches[count($matches)-1][0];
	echo $required_match;
}

Open in new window

0
 
LVL 2

Author Comment

by:trg_dk
ID: 23003001
Works perfect :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question