473,471 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to match regular expression from right to left

hi, I'm a newbie to perl :-p

I want to parse this kind of string:
/main/abcd/efgh/hhh/3

to get the rightmost string that is enclosed in '/'. In this case, it's
'hhh'.

So, how to do this in Perl? something as '=~ /\/(.*)\//' ?

or use index()?

Thanks in advance,
Liang


Jul 19 '05 #1
2 9876
Liang wrote:
hi, I'm a newbie to perl :-p

I want to parse this kind of string:
/main/abcd/efgh/hhh/3

to get the rightmost string that is enclosed in '/'. In this case,
it's 'hhh'.


So you want to learn about regular expressions? Start here:

http://www.perldoc.com/perl5.8.4/pod/perlrequick.html

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2
"Liang" <le*********@hotmail.com> wrote in message news:<cg**********@newshost.mot.com>...

I want to parse this kind of string:
/main/abcd/efgh/hhh/3

to get the rightmost string that is enclosed in '/'. In this case, it's
'hhh'.

So, how to do this in Perl? something as '=~ /\/(.*)\//' ?


/.*\/(.*)\//

This newsgroup does not exist (see FAQ). Please do not start threads here.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ron Adam | last post by:
Is it possible to match a string to regular expression pattern instead of the other way around? For example, instead of finding a match within a string, I want to find out, (pass or fail), if...
12
by: Joerg Schuster | last post by:
Hello, The program given below returns the lines: a ab Is there a way to use python regular expressions such that the program would return the following lines?
2
by: Charles Nadeau | last post by:
Hello, I am trying to craft a regular expression to filter an URL from a <a href=""></a> tag and the one I have doesn't seen right. I use the regular expression from this snippet of code: ...
1
by: Venkat | last post by:
Hi, I am using match function of string to find if a character is there in a string. The function Match is working fine with all the other characters except when the searching character is "+"....
2
by: Christian Staffe | last post by:
Hi, I would like to check for a partial match between an input string and a regular expression using the Regex class in .NET. By partial match, I mean that the input string could not yet be...
12
by: Jed Ozone | last post by:
New to Regex and I'm having a hard time figuring this one out. I need a regular expression what will based on balanced square brackets. For example: ], ,CC], ]] I'm trying to write a reg ex...
38
by: Steve Kirsch | last post by:
I need a simple function that can match the number of beginning and ending parenthesis in an expression. Here's a sample expression: ( ( "john" ) and ( "jane" ) and ( "joe" ) ) Does .NET have...
19
by: konrad Krupa | last post by:
I'm not expert in Pattern Matching and it would take me a while to come up with the syntax for what I'm trying to do. I hope there are some experts that can help me. I'm trying to match...
12
by: cmk128 | last post by:
Hi PHP's regular expression look like doesn't support .*? syntax. So i cannot match the shortest match. For exmaple: $str="a1b a3b"; $str1=ereg_replace("a.*b", "peter", $str1); will produce...
14
by: Andy B | last post by:
I need to create a regular expression that will match a 5 digit number, a space and then anything up to but not including the next closing html tag. Here is an example: <startTag>55555 any...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.