473,324 Members | 2,196 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,324 software developers and data experts.

need help on regular expression pattern

Hi,
I am looking for a regular expression that will find something like
that
"Word.word"
But also:
"Word.*"

I came up with:
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

each 'word' begins with a letter and can have numbers after it, and
can have brackets. It all works, but fails when I want to find the 2nd
example, like 'something.*', (last word can be a * in addition to
just text) which is where I am stuck. I originally started with this:

\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_][A-Za-z_0-9]*\]?\b

And then added the * there (the [A-Za-z_*] in:
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b) as part
of the character class. WHY DOES IT NOT FIND IT? Thanks!

Jan 8 '07 #1
4 1239
AB

<yo**@nobhillsoft.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,
I am looking for a regular expression that will find something like
that
"Word.word"
But also:
"Word.*"

I came up with:
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

did you forget about \ ?
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\. >>>\<<< [?[A-Za-z_*][A-Za-z_0-9]*\]?\b
Jan 8 '07 #2
Thanks for your quick response. but that wasnt the issue. i managed to
narrow it down to this:
before, i needed to search for a word, so something like
\b[?[A-Za-z_][A-Za-z_0-9]*\b was fine. now, the word may end with a *.
i cannot do this:

\b[?[A-Za-z_*][A-Za-z_0-9]*\b

because \b is ONLY AFTER A WORD CHARACTER, which * is not. i still want
to find it as a 'whole word', meaning i need the \b at the end, so i
discovered i can do something like:

\b[?[A-Za-z_*][A-Za-z_0-9]*\W

ending with \W instead of \b. one problem is this doesnt work at the
end of a string, which \b did. any idea how to fix it? find a substring
that ends with an asterik, either at the end of a string buffer or
anywhere in the middle of it

thanks!!

AB wrote:
<yo**@nobhillsoft.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,
I am looking for a regular expression that will find something like
that
"Word.word"
But also:
"Word.*"

I came up with:

\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

did you forget about \ ?
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\. >>>\<<< [?[A-Za-z_*][A-Za-z_0-9]*\]?\b
Jan 8 '07 #3

<yo**@nobhillsoft.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Thanks for your quick response. but that wasnt the issue. i managed to
narrow it down to this:
before, i needed to search for a word, so something like
\b[?[A-Za-z_][A-Za-z_0-9]*\b was fine. now, the word may end with a *.
i cannot do this:

\b[?[A-Za-z_*][A-Za-z_0-9]*\b

because \b is ONLY AFTER A WORD CHARACTER, which * is not. i still want
to find it as a 'whole word', meaning i need the \b at the end, so i
discovered i can do something like:

\b[?[A-Za-z_*][A-Za-z_0-9]*\W

ending with \W instead of \b. one problem is this doesnt work at the
end of a string, which \b did. any idea how to fix it? find a substring
This should match whitespace or end-of-string:

(\W|$)
that ends with an asterik, either at the end of a string buffer or
anywhere in the middle of it

thanks!!

AB wrote:
><yo**@nobhillsoft.comwrote in message
news:11*********************@s34g2000cwa.googlegr oups.com...
Hi,
I am looking for a regular expression that will find something like
that
"Word.word"
But also:
"Word.*"

I came up with:

\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

did you forget about \ ?
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\. >>>\<<<
[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

Jan 8 '07 #4
You need to spell out your rules more clearly. For example, you said that
"each 'word' begins with a letter and can have numbers after it, and can
have brackets." By that definition, you could mean any of the following:

A[]
[A123]
A123[456]
A{123}
{A}

The most important step to writing a good regular expression is to clearly
define the rules for the pattern.

--
HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

Where there's a Will, there's a William.

<yo**@nobhillsoft.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,
I am looking for a regular expression that will find something like
that
"Word.word"
But also:
"Word.*"

I came up with:
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b

each 'word' begins with a letter and can have numbers after it, and
can have brackets. It all works, but fails when I want to find the 2nd
example, like 'something.*', (last word can be a * in addition to
just text) which is where I am stuck. I originally started with this:

\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_][A-Za-z_0-9]*\]?\b

And then added the * there (the [A-Za-z_*] in:
\b\[?[A-Za-z_][A-Za-z_0-9]*\]?\.[?[A-Za-z_*][A-Za-z_0-9]*\]?\b) as part
of the character class. WHY DOES IT NOT FIND IT? Thanks!

Jan 9 '07 #5

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

Similar topics

14
by: Tina Li | last post by:
Hello, I've been struggling with a regular expression for parsing XML files, which keeps giving the run time error "maximum recursion limit exceeded". Here is the pattern string: ...
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...
1
by: Jeff | last post by:
For the life of me, I can't create a working regular expression for a schema pattern to do the following: Validates if an entire word does NOT match the entire word in the pattern. For...
3
by: rodchar | last post by:
hey all, what would my expression look like if i wanted to make sure that the input matched the following pattern. c:\filename.ext it doesn't have to be the c drive just a letter, colon,...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
3
by: shapper | last post by:
Hello, I have a regular expression to validate email addresses: "\w+(\w+)*@\w+(\w+)*\.\w+(\w+)*" Now I need to force all emails to be from a given domain, for example, accept only:...
6
by: rorymo | last post by:
I have a regular expression that allows only certain characters to be valid in an xml doc as follows: <xs:pattern value="^*" /> What I want to do is also allow any unicode character that is...
0
by: altavim | last post by:
Usually when you make regular expression to extract text you are starting from simple expression. When you got to know target text, you are extending your expression. Subsequently very hard to ready...
7
by: blaine | last post by:
Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.