Sponsored Content
Top Forums Shell Programming and Scripting PHP - Regex for matching string containing pattern but without pattern itself Post 302907474 by CarloM on Saturday 28th of June 2014 01:08:31 PM
Old 06-28-2014
I don't have PHP handy at the moment, but try:
Code:
preg_match_all ('/^(dept1|dept2|dept3)(.*)$/im', $curl_out, $userarray1, PREG_PATTERN_ORDER);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

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)
Discussion started by: imas
4 Replies

2. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

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)
Discussion started by: d.chauliac
4 Replies

3. Shell Programming and Scripting

Get matching string pattern from a file

Hi, file -> temp.txt cat temp.txt /home/pradeep/123/a_asp.html /home/pradeep/123/a_asp1.html /home/pradeep/435/a_asp2.html /home/pradeep/arun/abc/a_dfr.html /home/pradeep/arun/123/a_kir.html /home/pradeep/123/arun/a_dir.html .... .... .. i need to get a_*.html(bolded strings... (4 Replies)
Discussion started by: pradebban
4 Replies

4. Shell Programming and Scripting

Fetching string after matching pattern from last

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)
Discussion started by: saluja.deepak
3 Replies

5. UNIX for Dummies Questions & Answers

Extracting sub-string matching the pattern.

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)
Discussion started by: NetBear
3 Replies

6. Shell Programming and Scripting

SED: Pattern repitition regex matching

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)
Discussion started by: Vryali
5 Replies

7. Shell Programming and Scripting

Sum of column matching pattern/string

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)
Discussion started by: Gem_In_I
4 Replies

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'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)
Discussion started by: essem
11 Replies

9. UNIX for Dummies Questions & Answers

String pattern matching and position

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)
Discussion started by: biowizz
5 Replies

10. Shell Programming and Scripting

Replace String matching wildcard pattern

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
REGEXITERATOR(3)							 1							  REGEXITERATOR(3)

The RegexIterator class

INTRODUCTION
This iterator can be used to filter another iterator based on a regular expression. CLASS SYNOPSIS
RegexIterator RegexIteratorextends FilterIterator Constants o const integer$MATCH0 o const integer$GET_MATCH1 o const integer$ALL_MATCHES2 o const integer$SPLIT3 o const integer$REPLACE4 o const integer$USE_KEY1 Methods o public RegexIterator::__construct (Iterator $iterator, string $regex, [int $mode = self::MATCH], [int $flags], [int $preg_flags]) o public bool RegexIterator::accept (void ) o public int RegexIterator::getFlags (void ) o public int RegexIterator::getMode (void ) o public int RegexIterator::getPregFlags (void ) o public string RegexIterator::getRegex (void ) o public void RegexIterator::setFlags (int $flags) o public void RegexIterator::setMode (int $mode) o public void RegexIterator::setPregFlags (int $preg_flags) Inherited methods o publicabstract bool FilterIterator::accept (void ) o public FilterIterator::__construct (Iterator $iterator) o public mixed FilterIterator::current (void ) o public Iterator FilterIterator::getInnerIterator (void ) o public mixed FilterIterator::key (void ) o public void FilterIterator::next (void ) o public void FilterIterator::rewind (void ) o public bool FilterIterator::valid (void ) PREDEFINED CONSTANTS
REGEXITERATOR OPERATION MODES
o RegexIterator::ALL_MATCHES - Return all matches for the current entry (see preg_match_all(3)). o RegexIterator::GET_MATCH - Return the first match for the current entry (see preg_match(3)). o RegexIterator::MATCH - Only execute match (filter) for the current entry (see preg_match(3)). o RegexIterator::REPLACE - Replace the current entry (see preg_replace(3); Not fully implemented yet) o RegexIterator::SPLIT - Returns the split values for the current entry (see preg_split(3)). REGEXITERATOR FLAGS
o RegexIterator::USE_KEY - Special flag: Match the entry key instead of the entry value. PHP Documentation Group REGEXITERATOR(3)
All times are GMT -4. The time now is 08:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy