This messy, but effective, addlinks() PHP function I wrote many years ago for the man pages has been working well over the years and continues to work well today. The only recent change is to add class="neo-man-link" to the links:
I was wonderiong if ther is a way for a user to add a man page specific to thier account. similar to copying the .1 or .1.gz to /usr/share/man/man1 "cp *.1.gz /usr/share/man/man1". Except for using another folder as I don't have access to /usr/share/man/man1. I would think that this might involve... (1 Reply)
Hi Guys,
I'm looking for the man page for scp version 1.2.27
I have an old redhat server that has a few large scripts that use this version and I want to know what the -A flag does and the man page is not on there. (4 Replies)
Man page is not working my system. It is giving the following the following error
> man ls
gdbm fatal: read error
with debug option
> man -d ls
...
....
...
...
using less as pager
checking for locale en_US
add_nls_manpath(): processing /usr/local/man:/usr/share/man:/usr/X11R6/man... (4 Replies)
Help,
it seem that i am unable to get man help form solaris 10.
I am running SunOS unknown 5.10 Generic_120012-14 i86pc i386 i86pc
when ever i try to man a command what i get is "No manual entry" like the one below.
# man grep
No manual entry for grep.
# man ls
No manual entry for ls.... (8 Replies)
What does the last change means in man page .. does that this man page has not been updated since 2003 or something else ?
newfs-options
The options are documented in the newfs man page.
SunOS 5.10 Last change: 9 Dec 2003 1
System... (2 Replies)
Just enabled Bootstrap for the advanced forum search page (desktop view):
https://www.unix.com/search.php
That' page still needs work, and to be converted from <table> elements to <div> elements, and to be redesigned, but in the meantime, it's OK using Bootstrap CSS.
Note: Before, we had... (0 Replies)
Discussion started by: Neo
0 Replies
LEARN ABOUT PHP
preg_replace_callback
PREG_REPLACE_CALLBACK(3) 1 PREG_REPLACE_CALLBACK(3)preg_replace_callback - Perform a regular expression search and replace using a callbackSYNOPSIS
mixed preg_replace_callback (mixed $pattern, callable $callback, mixed $subject, [int $limit = -1], [int &$count])
DESCRIPTION
The behavior of this function is almost identical to preg_replace(3), except for the fact that instead of $replacement parameter, one
should specify a $callback.
PARAMETERS
o $pattern
- The pattern to search for. It can be either a string or an array with strings.
o $callback
- A callback that will be called and passed an array of matched elements in the $subject string. The callback should return the
replacement string. This is the callback signature:
string handler (array $matches) You'll often need the $callback function for a preg_replace_callback(3) in just one place. In
this case you can use an anonymous function to declare the callback within the call to preg_replace_callback(3). By doing it this
way you have all information for the call in one place and do not clutter the function namespace with a callback function's name
not used anywhere else.
Example #1
preg_replace_callback(3) and anonymous function
<?php
/* a unix-style command line filter to convert uppercase
* letters at the beginning of paragraphs to lowercase */
$fp = fopen("php://stdin", "r") or die("can't read stdin");
while (!feof($fp)) {
$line = fgets($fp);
$line = preg_replace_callback(
'|<p>s*w|',
function ($matches) {
return strtolower($matches[0]);
},
$line
);
echo $line;
}
fclose($fp);
?>
o $subject
- The string or an array with strings to search and replace.
o $limit
- The maximum possible replacements for each pattern in each $subject string. Defaults to -1 (no limit).
o $count
- If specified, this variable will be filled with the number of replacements done.
RETURN VALUES preg_replace_callback(3) returns an array if the $subject parameter is an array, or a string otherwise. On errors the return value is NULL
If matches are found, the new subject will be returned, otherwise $subject will be returned unchanged.
CHANGELOG
+--------+---------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------+
| 5.1.0 | |
| | |
| | The $count parameter was added |
| | |
+--------+---------------------------------+
EXAMPLES
Example #2
preg_replace_callback(3) example
<?php
// this text was used in 2002
// we want to get this up to date for 2003
$text = "April fools day is 04/01/2002
";
$text.= "Last christmas was 12/24/2001
";
// the callback function
function next_year($matches)
{
// as usual: $matches[0] is the complete match
// $matches[1] the match for the first subpattern
// enclosed in '(...)' and so on
return $matches[1].($matches[2]+1);
}
echo preg_replace_callback(
"|(d{2}/d{2}/)(d{4})|",
"next_year",
$text);
?>
The above example will output:
April fools day is 04/01/2003
Last christmas was 12/24/2002
Example #3
preg_replace_callback(3) using recursive structure to handle encapsulated BB code
<?php
$input = "plain [indent] deep [indent] deeper [/indent] deep [/indent] plain";
function parseTagsRecursive($input)
{
$regex = '#[indent]((?:[^[]|[(?!/?indent])|(?R))+)[/indent]#';
if (is_array($input)) {
$input = '<div style="margin-left: 10px">'.$input[1].'</div>';
}
return preg_replace_callback($regex, 'parseTagsRecursive', $input);
}
$output = parseTagsRecursive($input);
echo $output;
?>
SEE ALSO
PCRE Patterns, preg_quote(3), preg_replace(3), preg_last_error(3), Anonymous functions, information about the callback type.
PHP Documentation Group PREG_REPLACE_CALLBACK(3)