473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

small Reg exp prob

Hello

I was wondering how to match car and the rest behind car using reg.exp?

/car black bla bla bla

so i can handle "car" and "black bla bla bla" seperately afterwards

TIA
/Lasse
Nov 15 '05 #1
4 1194
Hi Lasse,

It would probably be

^(car)([^$]+)$

Note: I don't really remember which of $ and ^ actually stands for the
beginning of line and the end of line. So you may have to swap these
characters to obtain a valid RegExp. My legend is:

^ stands for the beginning of line
$ stands for the end of line

Hope this helps.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
Hello

I was wondering how to match car and the rest behind car using reg.exp?

/car black bla bla bla

so i can handle "car" and "black bla bla bla" seperately afterwards

TIA
/Lasse


Nov 15 '05 #2
hmm not sure either, but "car" can be any length and not just "car"

it's more like:

/ followed by a Word, then a space, then Word(s)


"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi Lasse,

It would probably be

^(car)([^$]+)$

Note: I don't really remember which of $ and ^ actually stands for the
beginning of line and the end of line. So you may have to swap these
characters to obtain a valid RegExp. My legend is:

^ stands for the beginning of line
$ stands for the end of line

Hope this helps.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
Hello

I was wondering how to match car and the rest behind car using reg.exp?

/car black bla bla bla

so i can handle "car" and "black bla bla bla" seperately afterwards

TIA
/Lasse

Nov 15 '05 #3
Then it would look like

^([a-zA-Z]+)\s(([a-zA-Z]+)|$)+

You might also like to use the ExplicitCapture option to have meaningful
pieces grouped. For example, the outer parenthes after \s are not a
meaningful capture by themselves, only the inner ones are.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
hmm not sure either, but "car" can be any length and not just "car"

it's more like:

/ followed by a Word, then a space, then Word(s)


"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi Lasse,

It would probably be

^(car)([^$]+)$

Note: I don't really remember which of $ and ^ actually stands for the
beginning of line and the end of line. So you may have to swap these
characters to obtain a valid RegExp. My legend is:

^ stands for the beginning of line
$ stands for the end of line

Hope this helps.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
Hello

I was wondering how to match car and the rest behind car using reg.exp?
/car black bla bla bla

so i can handle "car" and "black bla bla bla" seperately afterwards

TIA
/Lasse



Nov 15 '05 #4
Dmitriy,

hmm, but i pass that string and want to get out the 2 stringvalues for the
first Word and then second variable Word(s)

/Lasse
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eW**************@TK2MSFTNGP11.phx.gbl...
Then it would look like

^([a-zA-Z]+)\s(([a-zA-Z]+)|$)+

You might also like to use the ExplicitCapture option to have meaningful
pieces grouped. For example, the outer parenthes after \s are not a
meaningful capture by themselves, only the inner ones are.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
hmm not sure either, but "car" can be any length and not just "car"

it's more like:

/ followed by a Word, then a space, then Word(s)


"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi Lasse,

It would probably be

^(car)([^$]+)$

Note: I don't really remember which of $ and ^ actually stands for the
beginning of line and the end of line. So you may have to swap these
characters to obtain a valid RegExp. My legend is:

^ stands for the beginning of line
$ stands for the end of line

Hope this helps.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
> Hello
>
> I was wondering how to match car and the rest behind car using

reg.exp? >
> /car black bla bla bla
>
> so i can handle "car" and "black bla bla bla" seperately afterwards
>
> TIA
> /Lasse
>
>


Nov 15 '05 #5

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

Similar topics

6
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is...
29
by: Thomas | last post by:
Hi I have an XSL stylesheet: <xsl:for-each select="TRACKS/TRACK"> <tr class="TDL"> <td width="90%"><xsl:number value="position()" format="1" /> - <xsl:value-of select="TRACKTITLE"/></td>...
5
by: David Sobey | last post by:
Hi Sorry bout this basic prob. Got a file called file.obj. tryna read the first line from it as a string and print it to the screen. getting errors: #include "stdafx.h" #include <stdio.h>...
0
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME ...
2
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.