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

GREP


i want to frame a grep command which is successful if and only if the
line contains ONLY alphabets and spaces no special characters and
digits are allowed
Jan 23 '08 #1
14 2135

"Rishi" <po*******@gmail.comwrote in message
i want to frame a grep command which is successful if and only if the
line contains ONLY alphabets and spaces no special characters and
digits are allowed
Try comp.lang.perl.

Regular expressions are an integeral part of Perl. In C you have to get the
library yourself, and syntax differs.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 23 '08 #2
Malcolm McLean wrote:
>
"Rishi" <po*******@gmail.comwrote in message
>i want to frame a grep command which is successful if and only if the
line contains ONLY alphabets and spaces no special characters and
digits are allowed
Try comp.lang.perl.
Actually comp.unix.programmer might be more appropriate.

Jan 23 '08 #3
In article <0c**********************************@e4g2000hsg.g ooglegroups.com>,
Rishi <po*******@gmail.comwrote:
>i want to frame a grep command which is successful if and only if the
line contains ONLY alphabets and spaces no special characters and
digits are allowed
You haven't defined "alphabets". Do you need to match the
German Eszett along with the (rather more common) Sanskrit ghnya ?
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes
Jan 23 '08 #4
Mark Bluemel <ma**********@pobox.comwrites:
Malcolm McLean wrote:
>"Rishi" <po*******@gmail.comwrote in message
>>i want to frame a grep command which is successful if and only if the
line contains ONLY alphabets and spaces no special characters and
digits are allowed
Try comp.lang.perl.

Actually comp.unix.programmer might be more appropriate.
If the original poster is really looking for a grep *command*,
comp.unix.shell is probably the right place.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jan 23 '08 #5
Malcolm wrote:
)Try simply receiving str as an unsigned char*
)>
) That would imply that str is in fact a buffer full of bytes, rather than a
) human-readable string.

Why does a human-readable string have to be 'char' and not 'unsigned char'?
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jan 24 '08 #6

"Willem" <wi****@stack.nlwrote in message
Malcolm wrote:

Why does a human-readable string have to be 'char' and not 'unsigned
char'?
Because "char" has been overworked. sizeof(char) is always one, so "char"
and "byte" are synonyms. With hindsight, a pointless decision, but now we've
got to live with it.
char means a human-readable character. It can have trap representations.
Conventionally a list of chars will be terminated by a nul, and most library
functions insist on that. Also an embedded string literal will be a char
array.

unsigned char means a byte. Not infrequently, for instance in compression
algorithms, you want to treat data as a list of bits or bytes.

Whilst conversions between char * and unsigned char * will generally result
in no code being executed, you are playing fast and loose with the C type
system by using them. They mean different things.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 24 '08 #7
Willem wrote:
Malcolm wrote:
)Try simply receiving str as an unsigned char*
)>
) That would imply that str is in fact a buffer full of bytes, rather than a
) human-readable string.

Why does a human-readable string have to be 'char' and not 'unsigned char'?
I think he has a point, *(unsigned char *)charptr and (unsigned
char)*charptr are different if char is signed and doesn't use 2's
complement and charptr points to a negative char.

--
Army1987 (Replace "NOSPAM" with "email")
Jan 24 '08 #8
Army1987 wrote:
) I think he has a point, *(unsigned char *)charptr and (unsigned
) char)*charptr are different if char is signed and doesn't use 2's
) complement and charptr points to a negative char.

Yes, but if a string contains non-ASCII characters, i.e. characters with
the high bit set, then are those defined in a signed or in an unsigned
context ?
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jan 24 '08 #9
Army1987 wrote:
I think he has a point, *(unsigned char *)charptr and (unsigned
char)*charptr are different if char is signed and doesn't use 2's
complement and charptr points to a negative char.
And I think that this has the interesting effect that `fputs(string,
stream);` and `fwrite(string, 1, strlen(string), stream);` could do
different things if string contains some negative chars and char is signed
with ones' complement or sign-and-magnitude.

For example, if string is
unsigned char string[2] = { 0xf0, 0 };
and char is 8-bits, sign and magnitude, the former will putc(-0x70,
stream), effectively writing 0x90 as putc converts its argument to
unsigned char, reducing it modulo 0x100, and the latter will putc(0xfo,
stream).

Or will they?
--
Army1987 (Replace "NOSPAM" with "email")
Jan 24 '08 #10
In article <sl********************@snail.stack.nl>, Willem
<wi****@stack.nlwrites
>Malcolm wrote:
)Try simply receiving str as an unsigned char*
)>
) That would imply that str is in fact a buffer full of bytes, rather than a
) human-readable string.

Why does a human-readable string have to be 'char' and not 'unsigned char'?
Because signed and unsigned char are integer types.
Plain char is a character type

It is implementation defined as to weather the plain char is signed to
unsigned in the implementation.

So for char you should always explicitly use signed or unsigned for data
but plain char for Characters

MISRA-C for example defines
int8_t
uint8_t
char_t

to keep them separate

When you typeddef to char_t you should not what your specific
implementation does. Signed or uinsigned

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jan 25 '08 #11
Chris Hills wrote:
Willem <wi****@stack.nlwrites
>>
.... snip ...
>>
Why does a human-readable string have to be 'char' and not
'unsigned char'?

Because signed and unsigned char are integer types.
Plain char is a character type

It is implementation defined as to weather the plain char is
signed to unsigned in the implementation.
Not so. Most of the characters, and especially the required C char
set, are required to be positive, and thus can be expressed in
unsigned chars. This is why systems with 8 bit bytes using EBCDIC
have to define char as unsigned. Unsigned char also covers the
complete range of the ASCII char set.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 25 '08 #12
CBFalconer <cb********@yahoo.comwrites:
Chris Hills wrote:
>Willem <wi****@stack.nlwrites
>>>
... snip ...
>>>
Why does a human-readable string have to be 'char' and not
'unsigned char'?

Because signed and unsigned char are integer types.
Plain char is a character type

It is implementation defined as to weather the plain char is
signed to unsigned in the implementation.

Not so. Most of the characters, and especially the required C char
set, are required to be positive, and thus can be expressed in
unsigned chars. This is why systems with 8 bit bytes using EBCDIC
have to define char as unsigned. Unsigned char also covers the
complete range of the ASCII char set.
It's clearly implementation-defined whether the the plain char type is
signed or unsigned, which I presume is what Chris meant.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jan 25 '08 #13
In article <87************@kvetch.smov.org>, Keith Thompson
<ks***@mib.orgwrites
>CBFalconer <cb********@yahoo.comwrites:
>Chris Hills wrote:
>>Willem <wi****@stack.nlwrites
... snip ...
>>>>
Why does a human-readable string have to be 'char' and not
'unsigned char'?

Because signed and unsigned char are integer types.
Plain char is a character type

It is implementation defined as to weather the plain char is
signed to unsigned in the implementation.

Not so. Most of the characters, and especially the required C char
set, are required to be positive, and thus can be expressed in
unsigned chars. This is why systems with 8 bit bytes using EBCDIC
have to define char as unsigned. Unsigned char also covers the
complete range of the ASCII char set.

It's clearly implementation-defined whether the the plain char type is
signed or unsigned, which I presume is what Chris meant.
Yes..... I once did (many years ago) a survey into this point and whilst
the majority went one way several others went the other way.

When string handling it is usually not important but for other
manipulations it can cause problems. So you do need to know what your
implementation uses. It can play havoc with portability
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jan 26 '08 #14

"Chris Hills" <ch***@phaedsys.orgwrote in message
>
When string handling it is usually not important but for other
manipulations it can cause problems. So you do need to know what your
implementation uses. It can play havoc with portability
My crossword generator probably won't do non-English crosswords. Certainly
not nicely. The letters have got to be written to html files.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 26 '08 #15

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

Similar topics

13
by: sf | last post by:
Just started thinking about learning python. Is there any place where I can get some free examples, especially for following kind of problem ( it must be trivial for those using python) I have...
2
by: John E. Jardine | last post by:
Hi, Problem: Executing 's///' has a side effect on grep null string matching. If line 62, the substitution, is executed the last two values returned by grep and printed on lines 68, 69 are...
1
by: Al Belden | last post by:
Hi all, I've been working on a problem that I thought might be of interest: I'm trying to replace some korn shell scripts that search source code files with perl scripts to gain certain features...
3
by: David Isaac | last post by:
What's the standard replacement for the obsolete grep module? Thanks, Alan Isaac
4
by: agarwalpiyush | last post by:
Hello, I am going nuts with trying to get the following to work: This is what I intend to do: I have a line in /etc/syslog.conf which I need to delete based on ip-address provided to me in a...
4
by: js | last post by:
Just my curiosity. Can python beats perl at speed of grep-like processing? $ wget http://www.gutenberg.org/files/7999/7999-h.zip $ unzip 7999-h.zip $ cd 7999-h $ cat *.htm bigfile $ du -h...
15
by: tereglow | last post by:
Hello all, I come from a shell/perl background and have just to learn python. To start with, I'm trying to obtain system information from a Linux server using the /proc FS. For example, in...
3
by: MyMarlboro | last post by:
print Dumper(@data); _____________ $VAR1= '2008,Car,Medium1,5000'; $VAR2= '2008,Car,Medium2,5000'; $VAR3= '2007,Plane1,Medium1,20000'; $VAR4= '2006,Boat,Small1,20000'; $VAR5=...
13
by: Anton Slesarev | last post by:
I've read great paper about generators: http://www.dabeaz.com/generators/index.html Author say that it's easy to write analog of common linux tools such as awk,grep etc. He say that performance...
47
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000):...
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...
0
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...
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: 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)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.