11-23-2010
regexp: really tired, guru help needed...
Hello all! Please help me with the following complex regexp which works in egrep:
PHP Code:
egrep '\"http:\/\/ccc\.bbb\.com\/documents\/0000\/[0-9]{4}\/([^\.]+\.[a-z]{3})[^\"]*\"' my-file.html
But silently does not work in sed:
PHP Code:
sed "s/\"http:\/\/ccc\.bbb\.com\/documents\/0000\/[0-9]{4}\/([^\.]+\.[a-z]{3})[^\"]*\"/aaa/g" my-file.html
or
PHP Code:
sed 's/\"http:\/\/ccc\.bbb\.com\/documents\/0000\/[0-9]{4}\/([^\.]+\.[a-z]{3})[^\"]*\"/aaa/g' my-file.html
Just can't figure out what's wrong...
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have been toying with the idea of posting a thread asking for your dumbest mistakes so that we may all learn from each other.
"A smart man learns from his own mistakes,
A wise man learns from others' mistakes"
I think I will start us off. I haven't had too many that were really bad, but... (6 Replies)
Discussion started by: Kelam_Magnus
6 Replies
2. UNIX for Dummies Questions & Answers
Well I have a new hosting account. I love these guys, because they have everything I need, and give me everything I need, but at the cost of I must configure it myself. I am trying to create a subdomain, and they use raw zone access for dns administration. I have no idea how to configure the zone... (1 Reply)
Discussion started by: btmitch
1 Replies
3. UNIX for Advanced & Expert Users
I wanted to know what email app most Sun solaris / unix gurus use ? I have become quite NON microsoft in the last few months in my studying solaris..
thanks
simon2000 (6 Replies)
Discussion started by: simon2000
6 Replies
4. UNIX for Dummies Questions & Answers
Please forgive me if this is the wrong place for this post. I didn't see a good place to post this topic in. :D
I would like to know what's the most popular and reliable Java IDE out there nowadays? A FREE one would be awesome! :D
Thanks for your suggestion!
Cheers! (10 Replies)
Discussion started by: laila63
10 Replies
5. Shell Programming and Scripting
perl guru's,
what i think is, not simply writing a script...i like to write a script which must take less time to run and less memory use..i like to fine tune my program...
for ex, my program has a subroutine(1 file open &file close and 1print )
2if loops(1 file open &file close and... (2 Replies)
Discussion started by: sekar sundaram
2 Replies
6. AIX
Hi alls
I don't see any solution and I need to have feedback from other people...
On a test machine (AIX 5.1) I've installed OpenSSH software on it (with openssl, prng, etc...) like is described on IBM AIX Docs. To control the installation I've rebooted the machine and all was ok (CDE was... (15 Replies)
Discussion started by: nymus7
15 Replies
7. UNIX for Dummies Questions & Answers
Good Day,
Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp.
sed -n '/regexp/{n;p;}' filename
What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies
8. Shell Programming and Scripting
hello,
i'm recompiling some c++ code for OSX and there are some bugs as the configure is not picking up some libs like atlas, pastix, etc, it should be finding either in standard path or with pkgconfig but it's not so i'm rewriting the Makefile. C++ territory is a bit of a stretch with all of... (0 Replies)
Discussion started by: f77hack
0 Replies
FPUTCSV(3) 1 FPUTCSV(3)
fputcsv - Format line as CSV and write to file pointer
SYNOPSIS
int fputcsv (resource $handle, array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape_char = "
DESCRIPTION
fputcsv(3) formats a line (passed as a $fields array) as CSV and write it (terminated by a newline) to the specified file $handle.
PARAMETERS
o $handle
-The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by
fclose(3)).
o $fields
- An array of values.
o $delimiter
- The optional $delimiter parameter sets the field delimiter (one character only).
o $enclosure
- The optional $enclosure parameter sets the field enclosure (one character only).
o $escape_char
- The optional $escape_char parameter sets the escape character (one character only).
RETURN VALUES
Returns the length of the written string or FALSE on failure.
CHANGELOG
+--------+---------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------+
| 5.5.4 | |
| | |
| | The $escape_char parameter was added |
| | |
+--------+---------------------------------------+
EXAMPLES
Example #1
fputcsv(3) example
<?php
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
The above example will write the following to file.csv:
aaa,bbb,ccc,dddd
123,456,789
"""aaa""","""bbb"""
NOTES
Note
If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the
auto_detect_line_endings run-time configuration option may help resolve the problem.
SEE ALSO
fgetcsv(3).
PHP Documentation Group FPUTCSV(3)