REGEX, groups and matching 
Author Message
 REGEX, groups and matching

Hey guys, I'm just now learning about alot of the regex class capabilities.
I have been reading wrox string manipulation handbook.  I'm having a hard
time grasping how to do something and I am hoping you guys can help :)

I am trying to pull the following line apart

c:\path1\path2\path3\filesname.txt

I want the following to happen

Path="c:\path1\path2\part3"
Filename = "filename.txt"

I was playing around with groups try to use the \ as the group and to grab
the text after the last \  but I am having problems.

Any input would be appreciated!

--
------------------------


Whenever man comes up with a better mousetrap, nature immediately comes up
with a better mouse. - James Carswell



Sun, 28 Aug 2005 11:28:40 GMT  
 REGEX, groups and matching
You could skip regex altogether and try something like below. It does strip
the final "\" off of the directory, though.

Dim info As New System.IO.FileInfo("c:\path1\path2\path3\filesname.txt")

MsgBox(info.Name)

MsgBox(info.Directory.FullName)

-Robin

VB Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Hey guys, I'm just now learning about alot of the regex class
capabilities.
> I have been reading wrox string manipulation handbook.  I'm having a hard
> time grasping how to do something and I am hoping you guys can help :)

> I am trying to pull the following line apart

> c:\path1\path2\path3\filesname.txt

> I want the following to happen

> Path="c:\path1\path2\part3"
> Filename = "filename.txt"

> I was playing around with groups try to use the \ as the group and to grab
> the text after the last \  but I am having problems.

> Any input would be appreciated!

> --
> ------------------------


> Whenever man comes up with a better mousetrap, nature immediately comes up
> with a better mouse. - James Carswell



Mon, 29 Aug 2005 05:46:41 GMT  
 REGEX, groups and matching
Worked wonders.. Thankyou!


Quote:
> You could skip regex altogether and try something like below. It does
strip
> the final "\" off of the directory, though.

> Dim info As New System.IO.FileInfo("c:\path1\path2\path3\filesname.txt")

> MsgBox(info.Name)

> MsgBox(info.Directory.FullName)

> -Robin

> VB Team

> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.



> > Hey guys, I'm just now learning about alot of the regex class
> capabilities.
> > I have been reading wrox string manipulation handbook.  I'm having a
hard
> > time grasping how to do something and I am hoping you guys can help :)

> > I am trying to pull the following line apart

> > c:\path1\path2\path3\filesname.txt

> > I want the following to happen

> > Path="c:\path1\path2\part3"
> > Filename = "filename.txt"

> > I was playing around with groups try to use the \ as the group and to
grab
> > the text after the last \  but I am having problems.

> > Any input would be appreciated!

> > --
> > ------------------------


> > Whenever man comes up with a better mousetrap, nature immediately comes
up
> > with a better mouse. - James Carswell



Sat, 03 Sep 2005 05:15:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. RegEx: Pattern Matching going wrong: "\[.+\]\"

2. match [ (Regex)

3. Filename pattern matching using regex

4. regex question on multiple word matches

5. RegEx object - Pattern Matching

6. Regex library that supports groups?

7. RegExp question: match within another match

8. Seek Nearest Match if exact match not found ?

9. Seek Nearest Match if exact match not found ?

10. Grouping Tool Windows: tab group or tiled group

11. Stopping data from being grouped by Group 1 when that group is suppressed

12. RegEx - sorry to bother - found the solution

 

 
Powered by phpBB® Forum Software