03-02-2015
That's a neat trick to get the first character without using substrings in a crummy shell. I'll remember that.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
The way I've been using arrays currently have been:
#!/bin/ksh
set -A myArray
myArray=value1
myArray=value2
myArray=value3
myArray=value4
Is there a way I can assign values to an array that will automatically place the value into the next element in the array like:
myArray=value1... (4 Replies)
Discussion started by: yongho
4 Replies
2. Shell Programming and Scripting
I have to add a variable value to an array, something like this:
......
@my_array_name = $value_of_this_variable;
This doesnt seem to work, any ideas why?
Thanks! (4 Replies)
Discussion started by: looza
4 Replies
3. Shell Programming and Scripting
hi every body,
i donot know how to assign a array varible with a file
see i having file
more file
property1 Name
property2 Address
the above two line are tab Space seperated between the property and its value
i want to seperate it and assign to... (1 Reply)
Discussion started by: kkraja
1 Replies
4. Shell Programming and Scripting
I need to do something like this:
for i in 1 2 3 4 5; do
arr=$(awk 'NR="$i" { print $2 }' file_with_5_records)
done
That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop.
Is my... (2 Replies)
Discussion started by: fiori_musicali
2 Replies
5. Shell Programming and Scripting
Hello,
Can somebody please give me a snippet for the below requirement.
I want to assign the values separeted by a comma to be assigned to a dynamic array.
If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
Discussion started by: suneelj
2 Replies
6. Emergency UNIX and Linux Support
set -A matched #find referenced files.
for i in ${file_names_html}
do
counter_j=0
for j in ${file_names_minus_index}
do
match=`cat $i | grep... (1 Reply)
Discussion started by: robin_simple
1 Replies
7. Shell Programming and Scripting
I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value.
I was thinking the best way to... (1 Reply)
Discussion started by: billprice13
1 Replies
8. Shell Programming and Scripting
Hi ,
i have file which is having two fields in it (#delimited)
ABC#FILE_01.DAT
DEF#FILE_02.DAT
i want to write first field values to one array example A_01 and second field values to B_02 array
please let me know how to do this ,my final requirement i have send out a mail for each record... (2 Replies)
Discussion started by: kkabc789
2 Replies
9. Shell Programming and Scripting
I have a question on how can I assign a output of a function to a variable which is executed in background.
Here is my example
$ cat sample_program.sh
#!/bin/ksh
exec_func () {
sleep 1
v=`expr $1 + 100`
print $v
}
export OUT_ARR
date
for i in 1 2
do
OUT_ARR=`exec_func $i` &... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies
10. Shell Programming and Scripting
Hi,
I have the following code that makes use of a URL that I store in a variable then create a document object below to work on it.
$dom = new DOMDocument;
@$dom->loadHTML($html);
$links = $dom->getElementsByTagName('a');
$links = $dom->getElementsByTagName('a');
... (0 Replies)
Discussion started by: mojoman
0 Replies
LEARN ABOUT PHP
eregi_replace
EREGI_REPLACE(3) 1 EREGI_REPLACE(3)
eregi_replace - Replace regular expression case insensitive
SYNOPSIS
string eregi_replace (string $pattern, string $replacement, string $string)
DESCRIPTION
This function is identical to ereg_replace(3) except that this ignores case distinction when matching alphabetic characters.
Warning
This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
PARAMETERS
o $pattern
- A POSIX extended regular expression.
o $replacement
- If $pattern contains parenthesized substrings, $replacement may contain substrings of the form digit, which will be replaced
by the text matching the digit'th parenthesized substring; will produce the entire contents of string. Up to nine substrings
may be used. Parentheses may be nested, in which case they are counted by the opening parenthesis.
o $string
- The input string.
RETURN VALUES
The modified string is returned. If no matches are found in $string, then it will be returned unchanged.
EXAMPLES
Example #1
Highlight search results
<?php
$pattern = '(>[^<]*)('. quotemeta($_GET['search']) .')';
$replacement = '\1<span class="search">\2</span>';
$body = eregi_replace($pattern, $replacement, $body);
?>
NOTES
Note
As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED
notice. See the list of differences for help on converting to PCRE.
Tip
eregi_replace(3) is deprecated as of PHP 5.3.0. preg_replace(3) with the i ( PCRE_CASELESS) modifier is the suggested alternative.
SEE ALSO
ereg(3), eregi(3), ereg_replace(3), preg_replace(3), quotemeta(3).
PHP Documentation Group EREGI_REPLACE(3)