Sponsored Content
Top Forums Shell Programming and Scripting How to insert an array element within regex? Post 302852015 by drl on Tuesday 10th of September 2013 09:40:24 AM
Old 09-10-2013
Hi.

Create a variable with the regular expression characters, then use that variable in the match function.

Best wishes ... cheers, drl

Last edited by drl; 09-10-2013 at 04:21 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies

2. Shell Programming and Scripting

Reading Of Array Element in Unix

Hi, I am using the following command to initialize and array # arr=ffffff00 # echo $arr ffffff00 my requirement is i want to fetch the one by one character from array. I don't know how to fetch one by one charcter from array. Please i need an help. Thank you very much Ravi R N (2 Replies)
Discussion started by: ravi_rn
2 Replies

3. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

4. Shell Programming and Scripting

HELP unsetting array element in loop

I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that... (2 Replies)
Discussion started by: msf5042
2 Replies

5. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

6. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

7. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

8. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

9. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

10. Shell Programming and Scripting

How to insert a CSV within xml element tag using Python?

Hi Team, I have a CSV file which I have to read through and needs to insert the content within an XML file using Python ONLY ( as most of the code base we have in python only). I managed to find the first part, missing how to insert to XML under "specific" tags. cat input.csv... (0 Replies)
Discussion started by: panyam
0 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 10:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy