Sponsored Content
Full Discussion: Understanding a regex
Top Forums Shell Programming and Scripting Understanding a regex Post 302603779 by michaelrozar17 on Friday 2nd of March 2012 02:40:09 AM
Old 03-02-2012
In general this would mean \{m,n\}a minimum of 'm' numbers and maximum of 'n' numbers in length. Its actually the range. So

[0-9]\{6,10\} - this matches numbers of atleast 6 and atmost 10 in length, hence it matched: 20111210. If in case you have a dir which is say 20112 - this would not get displayed as it has totally/length 5 numbers, whereas our condition says to find with minimum of 6 numbers and a max of 10. Similarly in Sed

.[0-9]\{1,3\} after a dot find for number which is of minimum 1 and a max of 3 in length
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

2. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

3. Shell Programming and Scripting

help understanding regex with grep & sed

I have the following line of code that works wonders. I just don't completely understand it as I am just starting to learn regex. Can you help me understand exactly what is happening here? find . -type f | grep -v '^\.$' | sed 's!\.\/!!' (4 Replies)
Discussion started by: trogdortheburni
4 Replies

4. Shell Programming and Scripting

Understanding regex behaviour when using quantifiers

# echo "Teest string" | sed 's/e*/=>replaced=</' =>replaced<=Teest string So, in the above code , sed replaces at the start. does that mean sed using the pattern e* settles to zero occurence ? Why sed was not able to replace Teest string. # echo "Teest string" | sed 's/e*//g' Tst string ... (6 Replies)
Discussion started by: chidori
6 Replies

5. Shell Programming and Scripting

Need Quick help on Understanding sed Regex

Hi Guys, Could you please kindly explain what exactly the below SED command will do ? I am quite confused and i assumed that, sed 's/*$/ /' 1. It will remove tab and extra spaces .. with single space. The issue is if it is removing tab then it should be Î right .. please assist.... (3 Replies)
Discussion started by: Nandy
3 Replies

6. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. Shell Programming and Scripting

Need help understanding this Regex.

Hi everyone, This regex looks simple and yet it doesn't make sense how it's manipulating the output. ifconfig -a eth0 Link encap:Ethernet HWaddr 00:0c:49:c2:35:6v inet addr:192.16.1.1 Bcast:192.168.226.255 Mask:255.255.255.0 inet6 addr:... (2 Replies)
Discussion started by: xcod3r
2 Replies

8. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

9. UNIX for Beginners Questions & Answers

Help with understanding this regex in a Perl script parsing a 'complex' string

Hi, I need some guidance with understanding this Perl script below. I am not the author of the script and the author has not leave any documentation. I supposed it is meant to be 'easy' if you're a Perl or regex guru. I am having problem understanding what regex to use :confused: The script does... (3 Replies)
Discussion started by: newbie_01
3 Replies

10. Programming

Regarding a GREAT site for understanding and Visualizing regex patterns.

Hello All, While googling on regex I came across a site named Regulex Regulex:JavaScript Regular Expression Visualizer I have written a simple regex ^(a|b|c)(*)@(.*) and could see its visualization; one could export it too, following is the screen shot. ... (3 Replies)
Discussion started by: RavinderSingh13
3 Replies
mlib_ImageExtremaLocations(3MLIB)			    mediaLib Library Functions				 mlib_ImageExtremaLocations(3MLIB)

NAME
mlib_ImageExtremaLocations, mlib_ImageExtremaLocations_Fp - image extrema and their locations SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_ImageExtremaLocations( mlib_s32 *min, mlib_s32 *max, const mlib_image *img, mlib_s32 xStart, mlib_s32 yStart, mlib_s32 xPeriod, mlib_s32 yPeriod, mlib_s32 saveLocations, mlib_s32 maxRuns, mlib_s32 *minCounts, mlib_s32 *maxCounts, mlib_s32 **minLocations, mlib_s32 **maxLocations, mlib_s32 len); mlib_status mlib_ImageExtremaLocations_Fp( mlib_d64 *min, mlib_d64 *max, const mlib_image *img, mlib_s32 xStart, mlib_s32 yStart, mlib_s32 xPeriod, mlib_s32 yPeriod, mlib_s32 saveLocations, mlib_s32 maxRuns, mlib_s32 *minCounts, mlib_s32 *maxCounts, mlib_s32 **minLocations, mlib_s32 **maxLocations, mlib_s32 len); DESCRIPTION
Each of the functions finds the image-wise minimum and maximum pixel values for each channel, and optionally, their locations. Each of the functions scans an image, finds the minimum and maximum pixel values for each channel, and finds the locations of those pixels with the minimum or maximum values. The user provides initial minimum/maximum values through the arguments min and max. This function will update them based on findings. The set of pixels scanned may furthermore be reduced by specifying xPeriod and yPeriod parameters that specify the sampling rate along each axis. The set of pixels to be scanned may be obtained from the following equation: x = xStart + p*xPeriod; 0 <= p < (w - xStart)/xPeriod y = yStart + q*yPeriod; 0 <= q < (h - yStart)/yPeriod The locations of the minimum/maximum, if asked, are recorded in a format of run-length coding. Each run-length code, or simply called a run, has a format of (xStart, yStart, length). Here length is defined on the low-resolution image (with downsampling factors of 1/xPeriod, 1/yPeriod) and does not cross rows. So the run-length code (xStart, yStart, length) means that the pixels at (xStart, yStart), (xStart + xPeriod, yStart), ..., (xStart + (length - 1)*xPeriod, yStart) of the original image have a value of the minimum/maximum. The buffers for minLocations and maxLocations are organized in the following format for each channel i: minLocations[i][0] = xStart0; // the 1st run minLocations[i][1] = yStart0; minLocations[i][2] = length0; minLocations[i][3] = xStart1; // the 2nd run minLocations[i][4] = yStart1; minLocations[i][5] = length1; ...... // more runs minLocations[i][len-1] = ...; It is the user's responsibility to allocate enough memory for the buffers for minLocations and maxLocations. This function may return MLIB_OUTOFRANGE, if any of the buffers is not big enough. PARAMETERS
The function takes the following arguments: min Pointer to the minimum values. max Pointer to the maximum values. img Pointer to the input image. xStart Initial X sample coordinate. yStart Initial Y sample coordinate. xPeriod X sampling rate. xPeriod >= 1. yPeriod Y sampling rate. yPeriod >= 1. saveLocations If true (i.e., saveLocations != 0), find the extrema locations; otherwise only find the extrema. maxRuns Number of runs of the minimum/maximum the caller expects for each channel. maxRuns >= 1. If it is MLIB_S32_MAX, all the minimum/maximum locations should be recorded. minCounts Pointer to the numbers of runs of the minimum recorded in minLocations. maxCounts Pointer to the numbers of runs of the maximum recorded in maxLocations. minLocations Pointer to the minimum locations in a format of run-length coding. maxLocations Pointer to the maximum locations in a format of run-length coding. len Length of the buffers for the minimum/maximum locations in each channel. RETURN VALUES
The function returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_ImageExtrema2(3MLIB), mlib_ImageMaximum(3MLIB), mlib_ImageMaximum_Fp(3MLIB), mlib_ImageMinimum(3MLIB), mlib_ImageMinimum_Fp(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_ImageExtremaLocations(3MLIB)
All times are GMT -4. The time now is 05:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy