473,618 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular expression for numeric

Hi,

I would like to use regex.h to search for a pattern like the following:

"v1.2.54"

how can I achieve that?

Apr 21 '06 #1
10 2351

cybernerdsx2 wrote:
Hi,

I would like to use regex.h to search for a pattern like the following:

"v1.2.54"

how can I achieve that?

Dear friend,
You will use the "strstr() " function for search the
pattern.Its syntax is
strstr(s,t)
-It search the pattern "t" in the
string "s".
We have to include the user defined files ,then you create the file and
include like this
#include "regex.h".
Still you have you doubt mail to me.

Apr 21 '06 #2
Not very clear on your explaination there.

If I use strstr(), do I still need to use regex methods like regcomp,
regexec?

Apr 21 '06 #3
On 20 Apr 2006 21:16:09 -0700, "cybernerds x2" <fo*********@gm ail.com>
wrote:
Not very clear on your explaination there.

If I use strstr(), do I still need to use regex methods like regcomp,
regexec?


Look up strstr() in your C book, or man page if you're on *nix. If you
don't figure it out, come back.

--
Al Balmer
Sun City, AZ
Apr 21 '06 #4
"balasam" <bk*****@gmail. com> writes:
cybernerdsx2 wrote:
I would like to use regex.h to search for a pattern like the following:

"v1.2.54"

how can I achieve that?

That's a literal string. Is it supposed to be an example of the
pattern you're searching for?
You will use the "strstr() " function for search the
pattern.Its syntax is
strstr(s,t)
-It search the pattern "t" in the
string "s".
strstr() searches for a string, not for a regular expression.
We have to include the user defined files ,then you create the file and
include like this
#include "regex.h".


strstr() is a standard function, declared in <string.h>.

"regex.h" is not defined by the C standard. If your system provides
it, it should also provide documentation. Failing that, try a
newsgroup for your system (comp.unix.prog rammer, maybe?).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 21 '06 #5
Yes, "v1.2.54" is what I want to check. I might also need to check
something like this "v3.2.T33" (notice the 'T' before 33).

I have looked into strstr() but it only allows passing in char* for
searching. But that does not help formy situation here.

Apr 21 '06 #6

cybernerdsx2 wrote:
Hi,

I would like to use regex.h to search for a pattern like the following:

"v1.2.54"

how can I achieve that?


You'll have to ask somewhere where `regex.h` is known and topical. It
is not part of Standard C, so you're unlikely to get help here. Relpies
about `strstr()` are not going to be useful, unless you want to
implement regular expression searching yourself.

Apr 21 '06 #7
"cybernerds x2" <fo*********@gm ail.com> writes:
Yes, "v1.2.54" is what I want to check. I might also need to check
something like this "v3.2.T33" (notice the 'T' before 33).

I have looked into strstr() but it only allows passing in char* for
searching. But that does not help formy situation here.


Without context, it's difficult to tell what you're talking about.
Please read <http://cfaj.freeshell. org/google/>.

I don't understand why strstr() wouldn't serve your purpose. It
searches for a string in another string; the char* argument points to
the string.

You say that "v1.2.54" is what you want to check. Does that mean
you're looking specifically for "v1.2.54", not for "v1.2.55"?

What *exactly* are you trying to do? Showing some examples might be
helpful.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 21 '06 #8
okay, maybe i wasn't clear on this. When I say i want to check for
"v1.2.54" it is not fixed, meaning, my code needs to dynamically picks
up that I want to search for the version number on a application. That
application can changed to v1.3.4 and so on in the future.

So my program will have to pick up the pattern to check for that
version which will always be like this pattern : "vX.XX.AXXX " being X
as numeric and A as alphabet.

Hope this clears up the situation here?

Apr 21 '06 #9
"cybernerds x2" <fo*********@gm ail.com> writes:
okay, maybe i wasn't clear on this. When I say i want to check for
"v1.2.54" it is not fixed, meaning, my code needs to dynamically picks
up that I want to search for the version number on a application. That
application can changed to v1.3.4 and so on in the future.

So my program will have to pick up the pattern to check for that
version which will always be like this pattern : "vX.XX.AXXX " being X
as numeric and A as alphabet.

Hope this clears up the situation here?


You're still not providing context.

I already asked you to read <http://cfaj.freeshell. org/google/>.
Please do so now.

You might be able to use sscanf(); it doesn't support full regular
expressions, but it does let you search for simpler patterns.

But if you really want regular expressions, you'll have to use
facilities that are not provided by standard C. Either read your
system's documentation, or ask in a newsgroup appropriate to your
system. (Which is exactly what you've been told before.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 21 '06 #10

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

Similar topics

1
4163
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
5
1474
by: Ian Richardson | last post by:
I'm looking to use Javascript to pull apart a page of HTML I have already fetched. The page contains a table, within which there are rows containing... Either: 0000000 - 0000000<some html>00<some html>0 or:
8
3382
by: Ahmad A. Rahman | last post by:
Hi all, I have a problem constructing a regular expression using .net. I have a string, separated with comma, and I want to group the string together but, I failed to group a numeric character with decimal values. Example string : 1, 2.3, "two"," three" So, I want to group this string into 4 groups (1), (2.3), (two) and (three)
2
299
by: Peter Rietmann | last post by:
I have the problem to validate a password with a length of at least 6 and maximum 15 and the condition that it contains at least 2 numbers ie. (1aaaa1, aaaa11, 11aaaa). I am using the microsoft Regular Expreession Validation Control. I have tried the following at the web site http://www.regexlib.com/RETester.aspx ^(?=.*?\d.*?\d)({6,15})$
2
3009
by: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text index on one column, and punctuation in the column was causing some problems down the line. This column is used only for full text indexing, and otherwise ignored. I decided to use the following regular expression to remove all punctuation (actually...
7
12935
by: Tizzah | last post by:
What is wrong with that? regex = /^(http|https):\/\/+({1}+)*\.{2,5}(({1,5})?\/.*)?$/ if(field.hpage.value != regex.test(field.hpage.value)){ alert("Bad Homepage") field.hpage.focus() field.hpage.select() return false
1
1816
by: Bosconian | last post by:
I need a regular expression that will validate a double quote comma delimited list where the odd entries are numeric and the even are alphabetical. Each pair must also be on a separate line. For example: "1","Peter" "2","Paul" "3","Mary" I've used the following expression to validate comma delimited lists, but without the double quotes, numeric/alpha pairing and line return
5
1731
by: Bosconian | last post by:
I need a comma delimited regular expression pattern with the followng restrictions: no leading and trailing white space no trailing comma double quoted numeric/alpha pairs each pair on a separate line For example:
7
1856
by: graphicsxp | last post by:
Hi, I can't figure out what the regular expression would look like for validating a string such as : Lastname, Firstname I could only come up with /\w/ which doesn't check for the comma. Can someone help ?
1
1268
by: pranaysharmadelhi | last post by:
I want to generate a regular expression for password check.(ASP.Net) But javascript is what it really is. I would like to enforce Minimum 6 alphanumeric characters with minimum 1 numeric(0-9) and 1 character(a-z) or 1 Special Character(. or _) So far I have been able to generate something so they enter 6 alpha numberic characters, but don't know a way to check presence of 1 numeric and 1 alpha-numeric characted(or special). "^(){6}$" ...
0
8212
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8153
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8653
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8455
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6101
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4065
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.