Sponsored Content
Top Forums Shell Programming and Scripting Free regular expression interpreter for NT... Post 30346 by Vishnu on Monday 21st of October 2002 09:30:29 AM
Old 10-21-2002
OK, I will tell the real purpose...

We are installing event based scheduler on NT, which could be called from command line (and thus batch file) which monitors several machines, drives, directories for changes to groups of certain "hot files" and take actions as prescribed in its list.

We would need a regular expression interpreter source, so that we kind of include the headers in our C sources and be able to compile and call the functions in the interface -- like regexp() -- and use them in conjunction with the aforesaid event based scheduler.

I have tried isolating the regular expression routines and headers used by utilities like grep, on my Red Hat Linux 7.3 . And tried whether I can use the same source to compile with a C compiler on windows. But I'm now more of bewildered about how to go about this!

Could some body point me the relevant header and source files in linux which I can isolate and compile with simple C programs on windows and be able to call the standard regular expression functions like regexp() etc?

Thanks for your help!
Vishnu.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies

2. Programming

help in regular expression

Hi all, I'm working with flex (version 2.5.4a) on GNU/linux. I need to frame a regular expression which would match cases where word "file" does not occur. Negated character class wont work for me because they enforce "or" clause between different chars (so something like wont work). I would like... (5 Replies)
Discussion started by: Rakesh Ranjan
5 Replies

3. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

4. UNIX for Dummies Questions & Answers

ls with regular expression

I currently list and sort all the files in a directory which begin with an Upper Case C and end with the extension '#finished#'. Here is the command I use: ls -tr $currentDir/*.#finished# what i need to do now is list all the files in a directory that begin with upper case C and end... (3 Replies)
Discussion started by: rkgudde
3 Replies

5. Shell Programming and Scripting

Regular expression

Hi, How can I traverse backward in a string. I want second last directory in a path. For eg, /home/devel/scripts/shell/2009/test.sh I want 2009 here (6 Replies)
Discussion started by: gentleDean
6 Replies

6. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

7. Shell Programming and Scripting

Regular expression

I have a flat tab delimited file of the following format 1 A:23 A:45 A:789 2 A:2 A:47 3 A:78 A:345 A:9 A:10 4 A:34 A:98 I want to modify the file to the following format with insertions of "//" in between 1 A:23 // A:45 // A:789 2 A:2 // A:47 3 A:78 // A:345 // A:9 // A:10 4 A:34... (7 Replies)
Discussion started by: Lucky Ali
7 Replies

8. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

9. Shell Programming and Scripting

?* regular expression in sh

Hi, what ?* means in sh script? I know that ? is equivalent to at least one appearance of a preceding expression and * is equivalent to at least one appearance of preceding expression but I have difficulties with a way in which I should interpret following pattern: -?* I would expect that... (4 Replies)
Discussion started by: DavidMax
4 Replies

10. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies
regexp(3X)																regexp(3X)

NAME
compile(), step(), advance() - regular expression compile and match routines SYNOPSIS
Remarks Features documented in this manual entry are obsolescent and may be removed in a future HP-UX release. Use of regcomp(3C) functions instead is recommended. DESCRIPTION
These functions are general-purpose regular expression matching routines to be used in programs that perform Basic Regular Expression (see regexp(5)) matching. These functions are defined in The functions and do pattern matching given a character string and a compiled regular expression as input. takes a Basic Regular Expres- sion as input and produces a compiled expression that can be used with and The interface to this file is unpleasantly complex. Programs that include this file must have the following five macros declared before the statement. These macros are used by the routine. Return the value of the next byte in the regular expression pattern. Successive calls to should return successive bytes of the regular expression. Return the next byte in the regular expression. Successive calls to should return the same byte (which should also be the next byte returned by Cause the argument c to be returned by the next call to (and No more than one byte of pushback is ever needed, and this byte is guaranteed to be the last byte read by The value of the macro is always ignored. This macro is used on normal exit of the routine. The value of the argument pointer is a pointer to the character after the last character of the compiled regular expression. This is useful to programs that must manage memory allocation. This is the abnormal return from the routine. The argument val is an error number (see table below for meanings). This call should never return. 11 Range endpoint too large. 16 Bad number. 25 ``digit'' out of range. 36 Illegal or missing delimiter. 41 No remembered search string. 42 imbalance. 43 Too many 44 More than 2 numbers given in 45 expected after 46 First number exceeds second in 49 imbalance. 50 Regular expression overflow. The syntax of the routine is as follows: The first parameter instring is never used explicitly by the routine, but is useful for programs that pass down different pointers to input characters. It is sometimes used in the declaration (see below). Programs that call functions to input characters or have characters in an external array can pass down a value of for this parameter. The next parameter expbuf is a character pointer. It points to the location where the compiled regular expression will be placed. The parameter endbuf is one more than the highest address where the compiled regular expression can be placed. If the compiled expression cannot fit in (endbuf-expbuf) bytes, a call to is made. The parameter eof is the character which marks the end of the regular expression. For example, in ed(1), this character is usually a Each program that includes this file must have a statement for This definition is placed right after the declaration for the function and the opening curly brace It is used for dependent declarations and initializations. Most often it is used to set a register variable to point to the beginning of the regular expression so that this register variable can be used in the declarations for and Otherwise it can be used to declare external variables that might be used by and See the example below of the declarations taken from grep(1). also performs actual regular expression matching in this file. The call to step is as follows: The first parameter to is a pointer to a string of characters to be checked for a match. This string should be null-terminated. The second parameter expbuf is the compiled regular expression that was obtained by a call to returns non-zero if the given string matches the regular expression, and zero if the expressions do not match. If there is a match, two external character pointers are set as a side effect to the call to The variable set in is This is a pointer to the first character that matched the regular expression. The variable which is set by the function points to the character after the last character that matches the regular expression. Thus, if the regular expression matches the entire line, points to the first character of string and points to the null at the end of string. uses the external variable which is set by if the regular expression begins with If this is set, tries to match the regular expression to the beginning of the string only. If more than one regular expression is to be compiled before the first is executed, the value of circf should be saved for each compiled expression and circf should be set to that saved value before each call to is called from with the same arguments as The purpose of is to step through the string argument and call until returns non-zero, which indicates a match, or until the end of string is reached. To constrain string to beginning-of-line in all cases, need not be called; sim- ply call When encounters a or sequence in the regular expression, it advances its pointer to the string to be matched as far as possible and recur- sively calls itself, trying to match the rest of the string to the rest of the regular expression. As long as there is no match, advance backs up along the string until it finds a match or reaches the point in the string that initially matched the or It is sometimes desirable to stop this backing up before the initial point in the string is reached. If the external character pointer is equal to the point in the string at sometime during the backing up process, breaks out of the loop that backs up and returns zero. This is used by ed(1) and sed(1) for substitutions done globally (not just the first occurrence, but the whole line) so, for example, expressions such as do not loop for- ever. The additional external variables and are used for special purposes. EXTERNAL INFLUENCES
Locale The category determines the collating sequence used in compiling and executing regular expressions. The category determines the interpretation of text as single and/or multi-byte characters, and the characters matched by character class expressions in regular expressions. International Code Set Support Single- and multi-byte character code sets are supported. EXAMPLES
The following is an example of how the regular expression macros and calls look from grep(1): ... ... SEE ALSO
grep(1), regcomp(3C), setlocale(3C), regexp(5). STANDARDS CONFORMANCE
regexp(3X)
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy