Well, I don't understand this thread. First of all:
so the command given in the OP results in an array with a single element. To replicate that behavior:
but if you want to split it into separate array elements do:
if this is not working for you, you probably have IFS set wrong:
Hello,
I am an intermediate scripter. I can usually find and adapt what I need by searching through previous postings, but I'm stumped.
I have a string with the format "{Name1 Release1 Type1 Parent1} {Name2 Release2 Type2 Parent2}". It is being passed as an argument into a ksh script. I need to... (5 Replies)
I want to run an awk split on a value that has been pushed through an array and I was wondering what the syntax should be??
e.g. running time strings through an array and trying to examine just minutes:
12:25:30
10:15:13
08:55:23
awk '
NR==FNR{
... (2 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Hi all,
I want to split a string into array based on given delimiter, for example:
String:
"foo|bar|baz"
with delimiter "|"
into array:
strArr to strArr with values foo, bar and baz.
Thanks a lot.
Roy987 (5 Replies)
KSH
HP-SOL-Lin
Cannot use xAWK
I have several strings that are quite long and i want to break them down into smaller substrings.
What I have
String = "word1 word2 word3 word4 .....wordx"
What I want
String1="word1 word2"
String2="word 3 word4"
String3="word4 word5"
Stringx="wordx... (5 Replies)
Hi
Input:
{ committed = 782958592; init = 805306368; max = 1051394048; used = 63456712; }
Result:
A map (maybe Associative Array) where I can iterate through the key/value. Something like this:
for key in $map
do
echo key=$key value=$map
done
Sample output from the map:
... (2 Replies)
value=malayalam
# i need to store the value in an array by splitting the character
#the output i need is
m
a
l
a
y
a
l
a
m
Please use CODE tags for output data as well as required by forum rules! (5 Replies)
Test1.txt
Tom is hot
Test.sh
filename="/directory/Test1.txt"
set - A store
while IFS= read value
do
awk '{split($value,store," ")}'
done < "$filename"
echo ${#sore}
From the code in the executing file, I would like each... (8 Replies)
Discussion started by: TestKing
8 Replies
LEARN ABOUT PHP
spliti
SPLITI(3) 1 SPLITI(3)spliti - Split string into array by regular expression case insensitiveSYNOPSIS
array spliti (string $pattern, string $string, [int $limit = -1])
DESCRIPTION
Splits a $string into array by regular expression.
This function is identical to split(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
- Case insensitive regular expression. If you want to split on any of the characters which are considered special by regular
expressions, you'll need to escape them first. If you think spliti(3) (or any other regex function, for that matter) is doing
something weird, please read the file regex.7, included in the regex/ subdirectory of the PHP distribution. It's in manpage for-
mat, so you'll want to do something along the lines of man /usr/local/src/regex/regex.7 in order to read it.
o $string
- The input string.
o $limit
- If $limit is set, the returned array will contain a maximum of $limit elements with the last element containing the whole rest
of $string.
RETURN VALUES
Returns an array of strings, each of which is a substring of $string formed by splitting it on boundaries formed by the case insensitive
regular expression $pattern.
If there are n occurrences of $pattern, the returned array will contain n+1 items. For example, if there is no occurrence of $pattern, an
array with only one element will be returned. Of course, this is also true if $string is empty. If an error occurs, spliti(3) returns
FALSE.
EXAMPLES
This example splits a string using 'a' as the separator :
Example #1
spliti(3) example
<?php
$string = "aBBBaCCCADDDaEEEaGGGA";
$chunks = spliti ("a", $string, 5);
print_r($chunks);
?>
The above example will output:
Array
(
[0] =>
[1] => BBB
[2] => CCC
[3] => DDD
[4] => EEEaGGGA
)
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
spliti(3) is deprecated as of PHP 5.3.0. preg_split(3) with the i ( PCRE_CASELESS) modifier is the suggested alternative.
SEE ALSO preg_split(3), split(3), explode(3), implode(3).
PHP Documentation Group SPLITI(3)