Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Doubt with regexp-meta character Post 302452677 by dragon.1431 on Sunday 12th of September 2010 03:47:07 PM
Old 09-12-2010
MySQL Doubt with regexp-meta character

Hi,
I am learning reg exp a bit Smilie

Code:
Meta char info:
{n,m} Matches the preceding character at least n times but not more than m  times, for example, 'ba{2,3}b' will find 'baab' and 'baaab' but NOT  'bab' or 'baaaab'. Values are enclosed in braces (curly brackets).

Input file:
Code:
112
11112
1112
111112
1111112
11111112
111111112
1111111112

code used:
Code:
grep '11\{2,4\}2' ip.txt

I thought i will get minimum of 2 to maximum of 4.I want to get
Expected output:
Code:
1112
11112
111112

Actual output ,i got:
Code:
11112
1112
111112
1111112
11111112
111111112
1111111112

Is this correct? If yes can some one please explain me .

Thanks a lot in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tcl: regexp matching special character

Hello Experts, Can someone help me here: I have a variable which contains a string with "". set var1 {a} set str1 {a is the element i want to match} Now "regexp $var1 $str1" does not work? ("regexp {a\} $str1" works, but var1 gets it's value automatically from another script) Is... (6 Replies)
Discussion started by: sumitgarg
6 Replies

2. Shell Programming and Scripting

Perl RegExp to remove last character from strings

I use SAS (a statistical software) and have to remove last character or the last 1/2 numbers that appear after characters from the string using Perl Regular Expression (which is recognized by SAS). Input: f183ii10 f183ii2 f182ii1 f182ii2 f183iim f22ii f22ii11 f22ii12 pmh4 pmhm Desired... (2 Replies)
Discussion started by: ospreyeagle
2 Replies

3. Shell Programming and Scripting

What is the meta character for the Ctrl button?

In this script I have, it says press Ctrl+W+? for help, but it doesn't do anything. I looked in the script and it binds: bind ^W meta2_character. How do I make it the Ctrl button so I can do Ctrl+W? (There are some other commands that use Ctrl+W+another character/letter/number.) (4 Replies)
Discussion started by: guitarscn
4 Replies

4. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

5. Shell Programming and Scripting

rename - change n'th character of regexp

Hi, I wonder if its possible to do the following task using rename (perl v5.8.8). I want to find filenames matching the specific pattern and then change chosen character of this pattern to a given character, e.g. do the following renaming: regexp: 'ab' -----> 'a0b' What's the simplest... (0 Replies)
Discussion started by: pms
0 Replies

6. UNIX for Dummies Questions & Answers

Perl Meta character understanding

Hello All, I have some expression: if (/^(\d\d\d\d\d\.\d\d\d\d\d\d)\s+(.+)$/) { warn "$argv0(" . __LINE__ . "): rbl2ts{$2} == '$rbl2ts{$2}' \$1==$1\n" if ($debug); $rbl2ts{$2} = $1 if (!defined($rbl2ts{$2}) or ($1 le $rbl2ts{$2})); warn "$argv0(" . __LINE__ . "):... (3 Replies)
Discussion started by: suvenduperl
3 Replies

7. UNIX for Dummies Questions & Answers

List files using { } meta character

p { margin-bottom: 0.08in; } How to match all files that end with the release number using the { } meta character in /boot. (2 Replies)
Discussion started by: farash
2 Replies

8. Shell Programming and Scripting

Regexp for string that might contain a given character

I'm probably just not thinking of the correct term to search for :-) But I want to match a pattern that might be 'ABC' or '1ABC' there might be three characters, or there might be four, but if there are four, the first has to be 1 (1 Reply)
Discussion started by: jnojr
1 Replies

9. Shell Programming and Scripting

Filter non-alpha character with grep/regexp

Hi all, I am trying to filter out those lines that contain a "non-alpha" character. An example of my input is the following: zygnematales grb zygocactus grb zygocactus_truncatus plt zygodactyl_foot prt zygoma prt zygomatic prt zygomatic_arch prt zygomatic_bone ... (2 Replies)
Discussion started by: owwow14
2 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
WILDMAT(3)						     Library Functions Manual							WILDMAT(3)

NAME
wildmat - perform shell-style wildcard matching SYNOPSIS
int wildmat(text, pattern) char *text; char *pattern; DESCRIPTION
Wildmat is part of libinn (3). Wildmat compares the text against the pattern and returns non-zero if the pattern matches the text. The pattern is interpreted according to rules similar to shell filename wildcards, and not as a full regular expression such as those handled by the grep(1) family of programs or the regex(3) or regexp(3) set of routines. The pattern is interpreted as follows: x Turns off the special meaning of x and matches it directly; this is used mostly before a question mark or asterisk, and is not spe- cial inside square brackets. ? Matches any single character. * Matches any sequence of zero or more characters. [x...y] Matches any single character specified by the set x...y. A minus sign may be used to indicate a range of characters. That is, [0-5abc] is a shorthand for [012345abc]. More than one range may appear inside a character set; [0-9a-zA-Z._] matches almost all of the legal characters for a host name. The close bracket, ], may be used if it is the first character in the set. The minus sign, -, may be used if it is either the first or last character in the set. [^x...y] This matches any character not in the set x...y, which is interpreted as described above. For example, [^]-] matches any character other than a close bracket or minus sign. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> in 1986, and posted to Usenet several times since then, most notably in comp.sources.misc in March, 1991. Lars Mathiesen <thorinn@diku.dk> enhanced the multi-asterisk failure mode in early 1991. Rich and Lars increased the efficiency of star patterns and reposted it to comp.sources.misc in April, 1991. Robert Elz <kre@munnari.oz.au> added minus sign and close bracket handling in June, 1991. This is revision 1.10, dated 1992/04/03. SEE ALSO
grep(1), regex(3), regexp(3). WILDMAT(3)
All times are GMT -4. The time now is 10:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy