- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: regexp vs. GNU regexp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2006 11:33 PM
тАО04-23-2006 11:33 PM
i'm trying to get one script working with hp-ux's grep (porting from GNU's grep) and i've found different behavior. I'm asking here if someone could explain it:
Text (from comma separated values) which is GNU's grep (in Cygwin) selecting (according to my opinion) correctly and (extened) regular expresion is like this:
^X:([^,]*,){3}"C
i'm testing it (fourth comma separated value is like "C):
$ echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){3}"C'
X: A,,B,"C",,"D"
ok, match
$ echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){4}"C'
ok, it doesn't match
But with hp-ux's grep:
$ echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){3}"C'
X: A,,B,"C",,"D"
match, ok.
$ echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){4}"C'
X: A,,B,"C",,"D"
why this match?
echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){5}"C'
X: A,,B,"C",,"D"
also match. Why?
$ uname -a
HP-UX ccbdevd1 B.11.11 U 9000/800 610389312 unlimited-user license
thanks a lot!
Dusan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2006 01:28 AM
тАО04-24-2006 01:28 AM
SolutionIt does appear to be a bug :-(
manually expanded it works:
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){5}"C'
X: A,,B,"C",,"D"
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)([^,]*,)([^,]*,)([^,]*,)([^,]*,)"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)([^,]*,)([^,]*,)([^,]*,)([^,]*,)"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)([^,]*,)([^,]*,)([^,]*,)"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)([^,]*,)([^,]*,)"C'
X: A,,B,"C",,"D"
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)([^,]*,)"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,)"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){2}"C'
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){3}"C'
X: A,,B,"C",,"D"
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){4}"C'
X: A,,B,"C",,"D"
[root@vpart1 /]# echo 'X: A,,B,"C",,"D"'|grep -E '^X:([^,]*,){6}"C'
[root@vpart1 /]#
Even with regexbuilder (http://sourceforge.net/project/showfiles.php?group_id=76775) any variation other than
^X:([^,]*,){3}"C
is invalid
Report it as a bug.
I personally would use 'cut -d"," -f4' with grep "\"C\"", but that's not really the reported problem.
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2006 02:47 AM
тАО04-24-2006 02:47 AM
Re: regexp vs. GNU regexp
thanks for your reply.
It seems to me, it's in libc or where -- sed's behaviour is same.
$ echo 'X: A,,B,"C",,"D"'|sed 's/^X:\([^,]*,\)\{2\}"C/deleted/'
X: A,,B,"C",,"D"
$ echo 'X: A,,B,"C",,"D"'|sed 's/^X:\([^,]*,\)\{3\}"C/deleted/'
deleted",,"D"
$ echo 'X: A,,B,"C",,"D"'|sed 's/^X:\([^,]*,\)\{4\}"C/deleted/'
deleted",,"D"
$ echo 'X: A,,B,"C",,"D"'|sed 's/^X:\([^,]*,\)\{5\}"C/deleted/'
deleted",,"D"
also attached program reports false match.
btw, where can I report a bug?
(sorry, I've tryied "googling" over hp.com but didn't find
any useful links).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2006 02:53 AM
тАО04-24-2006 02:53 AM
Re: regexp vs. GNU regexp
Dusan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 01:41 AM
тАО04-25-2006 01:41 AM
Re: regexp vs. GNU regexp
You might find this tool very useful:
http://www.weitz.de/regex-coach/#install
This proves to be the best pattern:
^(X: )([^,]*,)([^,]*,)([^,]*,)(\"C\"\,)([^,]*,)([^,]*)
Using a ([^,]*,){3} instead of manually repeating it causes the pattern to backtrace and grab the same pattern twice. Try your different variations and use the STEP tab (near bottom of window) to walk through the string.
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2006 07:37 AM
тАО04-25-2006 07:37 AM
Re: regexp vs. GNU regexp
You can report bugs through "Support Case Manager" under the "Maintenance and support for hp products" link.
Marlou