I need to use it in php script. Calling awk from there sounds not good. Moreover i can split string into array and shift it, but i'd like to know regex-based solution just to extend my regex knowledge.
Hi,
I have file 1.txt with following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433
**
**
**
In file 2.txt I have the following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433... (4 Replies)
Hi all,
I'm looking for some help. I have a file (very long) that is organized like below:
>Cluster 0
0 283nt, >01_FRYJ6ZM12HMXZS... at +/99%
1 279nt, >01_FRYJ6ZM12HN12A... at +/99%
2 281nt, >01_FRYJ6ZM12HM4TS... at +/99%
3 283nt, >01_FRYJ6ZM12HM946... at +/99%
4 279nt,... (4 Replies)
I have a file a file having entries are like
@ram@sham@sita
@krishan@kumar
@deep@kumar@hello@sham
in this file all line are having different no of pattern-@.
need to fetch the substring after the last pattern.
like
sita
kumar
sham
thanks in advance (3 Replies)
Hi,
I have a string looks like the following:
USERS 32767.9844 UNDOTBS1 32767.9844 SYSAUX 32767.9844 SYSTEM 32767.9844 EMS 8192 EMS 8192 EMS_INDEXES 4096 EMS_INDEXES 4096 8 rows selected.
How do I extract a sub-string to get the expected output as following:
EMS 8192
EMS_INDEXES 4096
... (3 Replies)
Fairly straightforward, but I'm having an awful time getting what I thought was a simple regex to work. I'll give the command I was playing with, and I'm aware why this one doesn't work (the 1,3 is off the A-Z, not the whole expression), I just don't know what the fix is:
Actual Output(s):
$... (5 Replies)
Hi All,
I have the following output file created as a result of one script called pattern_daily.log
$ cat pattern_daily.log
Approved|2|Wed, Oct 24, 2012 11:21:09 AM
Declined|1|Wed, Oct 24, 2012 11:21:15 AM
Approved|2|Wed, Oct 24, 2012 11:24:08 AM
Declined|1|Wed, Oct 24, 2012 11:24:18 AM... (4 Replies)
'Hi
I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match.
Which option is to be used to exclude the line containing the pattern?
sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
I am not an expert with linux, but following various posts on this forum, I have been trying to write a script to match pattern of charters occurring together in a file.
My file has approximately 200 million characters (upper and lower case), with about 50 characters per line. I have merged all... (5 Replies)
Hi,
I know how to replace a string with another in a file.
But, i wish to replace the below string pattern
EncryptedPassword="{gafgfa}]\asffafsf312a" i.e EncryptedPassword="<any random string>"
To
EncryptedPassword=""
i.e remove the random password to a empty string.
Can you... (3 Replies)
Discussion started by: mohtashims
3 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)