[Gambas-user] Re gular Expression Help
Stefano Palmeri
rospolosco at ...152...
Tue May 27 18:17:23 CEST 2008
Il Tuesday 27 May 2008 17:22:35 hinchy ha scritto:
> Yeah I thought about doing something like that, the thing is though, I
> won't always know how long the first word is. With the regex I can match
> until the first white space. Is there a way of doing that with text
> splitting? If so great. If not is there anywhere you could suggest I look
> for example regex implementation in gambas?
>
> Thanks again.
I don't understand your problem (my fault). Here's a way to
extracy only "sda".
DIM sStr, sOneDev AS String
SHELL "ls /dev | grep [sh]d[a-z]" TO sStr
FOR EACH sOneDev IN Split(sStr, "\n")
IF sOneDev = "sda" THEN BREAK
NEXT
PRINT sOneDev
Bye
>
> M0E Lnx wrote:
> > why not just do some text splitting to get what you need?
> >
> > If you have "sda1" and you only want "sda" out of that... you should
> > be able to go with Newstring=left(sStr, 3)
> >
> > On 5/27/08, hinchy <eoinhinchy at ...626...> wrote:
> >> keywords: regex, Regular Expression, regexp, pcre
> >>
> >> Hi guys,
> >>
> >> I've been struggling with the pcre component for a couple of days now.
> >> I'm
> >> running the command:
> >> SHELL "ls /dev | grep [sh]d[a-z]" TO sStr
> >>
> >> This will return something along the lines of:
> >> sda
> >> sda1
> >> sda2
> >>
> >> I then want to run the regular expression ^[^\s]*+ against sStr to
> >> return
> >> sda for saving in a different string but I can't for the life of my
> >> figure
> >> it out.
> >> Any ideas? I'm sure it's quite simple I just can't get it together.
> >> Thanks,
> >> Eoin
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Regular-Expression-Help-tp17488070p17488070.html
> >> Sent from the gambas-user mailing list archive at Nabble.com.
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>- This SF.net email is sponsored by: Microsoft
> >> Defy all challenges. Microsoft(R) Visual Studio 2008.
> >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >> _______________________________________________
> >> Gambas-user mailing list
> >> Gambas-user at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list