Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

regex halp

Name: Anonymous 2010-09-16 16:37

can anyone help with the following regex?
[0 or more whitespace characters] + #define + [1 or more whitespace characters] + NULL + [1 or more whitespace characters]

thank u

Name: Anonymous 2010-09-16 16:40

Read SICP

Name: Anonymous 2010-09-16 16:42

Just pipe a grep into another. Regexen appear to be too difficult. Observe:
cat *.h | grep NULL | grep define
You don't need to write a script for this. IHBT

Name: Anonymous 2010-09-16 16:46

(|\s|\s\s|\s\s\s|\s\s\s\s|\s\s\s\s\s|\s\s\s\s\s\s|\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s)#define(\s|\s\s|\s\s\s|\s\s\s\s|\s\s\s\s\s|\s\s\s\s\s\s|\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s)NULL(\s|\s\s|\s\s\s|\s\s\s\s|\s\s\s\s\s|\s\s\s\s\s\s|\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s)

Name: Anonymous 2010-09-16 16:50

>>4
asshole ;D

Name: Anonymous 2010-09-16 17:12

>>4
Oh man, if only a regex could use some modifier somehow to cover any number of whitespace characters!

Forget it, it'll never happen.

Name: Anonymous 2010-09-16 17:43

>>1
$ man grep, ``faggot''.

Name: Anonymous 2010-09-16 17:47

>>7
U MENA

$ grep '\[0 or more whitespace characters] \+ #define \+ \[1 or more whitespace characters\] \+ NULL \+ \[1 or more whitespace characters\]' file.c

?

Name: Anonymous 2010-09-16 17:52

>>8
GREP ZERO OR MORE WHITESPACE CHARACTERS PLUS DEFINE PLUS ONE OR MORE WHITESPACE CHARACTERS PLUS NULL PLUS ONE OR MORE WHITESPACE CHARACTERS MY\ ANUS.c

Name: Anonymous 2010-09-16 20:09

\s*#define\s+NULL\s+

Name: sage 2010-09-16 20:30

>>10
the greps, they do nothing

Name: Anonymous 2010-09-16 22:46

>>10
Someone always has to miss the point.

Name: Anonymous 2010-09-16 22:52

>>10
\s*#define\s+?NULL\s+?
OMG OPTIMIZED

Name: Anonymous 2010-09-17 9:23

"[[:space:]]?#define[[:space:]]+NULL[[:space:]]+"

I am doing it right.

Name: Anonymous 2010-09-17 13:19

>>14
You really aren't.

Name: Anonymous 2010-09-17 17:42

>>14
EXPERT POSIX PROGRAMMER

Name: sage 2010-09-17 18:57

>>15
lies

Name: Anonymous 2010-09-18 17:41

>>14

fuck your egrep

Name: Anonymous 2010-09-18 17:46

>>18
Bracket expressions are a feature of basic regular expressions. You don't need egrep for it.

Name: sage 2010-09-19 6:06

>>19

to run it in grep you need --extended-regexp which means you're egrepping.

Name: Anonymous 2010-09-19 11:54

>>20
No, you don't. Bracket expressions are a feature of basic regular expressions.

Name: Anonymous 2010-09-20 7:20

>>21
Yes, you do. At least in Ubuntu.

Name: Anonymous 2010-09-20 7:31

>>22
[hma@anuslandia:~] cat jews
sdf
hma
aSdf
234
xcv
sdfg34
anuses
[hma@anuslandia:~] grep "[[:digit:]]" jews
234
sdfg34
[hma@anuslandia:~] uname -a
Linux anuslandia 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:01:29 UTC 2009 i686 GNU/Linux

Name: Anonymous 2010-09-20 8:24

$ export POSIXLY_CORRECT=1
$ echo baaaaaaab | grep "ba+b"
$ echo baaaaaaab | grep -E "ba+b"
baaaaaaab
$ grep --version | head -n1
GNU grep 2.6.3

Name: Anonymous 2010-09-20 9:28

ronc@piggy:~$ grep --with-filename --line-number --recursive "[[:space:]]?#define[[:space:]]+NULL[[:space:]]+" /usr/include/

ronc@piggy:~$ grep --with-filename --line-number --recursive --extended-regexp "[[:space:]]?#define[[:space:]]+NULL[[:space:]]+" /usr/include/
/usr/include/linux/stddef.h:8:#define NULL 0
/usr/include/linux/stddef.h:10:#define NULL ((void *)0)

ronc@piggy:~$ uname -a
Linux piggy 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:17:33 UTC 2010 i686 GNU/Linux

Name: Anonymous 2010-09-20 9:46

Sheesh.

NULL = (void *)0

/thread.

Don't change these.
Name: Email:
Entire Thread Thread List