Are you aware that these stipulations will exclude a "linux-something" at the lines end from being removed because there will be no space afterwards? Maybe this is not what you want. Also notice that your clause 2 means that the space immediately following the word "linux-*" will be removed too.
If your goal is indeed to remove the last match too i'd suggest:
If you want to retain the blank following the word but would not want to add a space at the end of the string then this:
I hope this helps.
bakunin
Any of the two work, because the apt command uses space as argument separator, when there are one or more spaces at the end they are ignored and two or more spaces in any place are condensed into one.
if I have "abxcdxefx" and want to remove the x's with sed, how can I do this?
Thanks.
WHOOPS:
Just remembered:
echo "abxcdxefx" | sed s/x//g
Thanks for reading, though. (0 Replies)
Hi,
I need to unload some data from Informix database into text file.
But what happen is when i open the text file, some record split into 2 line, become uncomplete.
I had checked is due to some unregconized space in particular fields, i used many way to detect this unregconized space, but... (3 Replies)
but keep if does not
I have a file: --> my.out
foo: bar
foo: moo
blarg
i am on vacation
foo: goose
foo: lucy
foo: moose
foo: stucky
groover@monkey.org
foo: bozo
grimace@gonzo.net
dear sir - blargo blargo
foo: goon
foo: sloppy
foo: saudi
gimme gimme gimme (3 Replies)
I have a customer file now and would like to separate the names into two cells in a spreadsheet. Here is my data as an example:
SHAWN R KEEGAN
shawn r scroggin
Shawn Regan
Shawn Reilly
The first two have the middle initial so I'd like to include them in the "first name" field and the last... (11 Replies)
Hi,
I have requirement that I need to split my input file into two files based on a search pattern "abc"
For eg. my input file has below content
abc
defgh
zyx
I need file 1 with
abc
and file2 with
defgh
zyx
I can use grep command to acheive this. But with grep I need... (8 Replies)
Hi all,
Can anyone help me on this. I have several WP sites that are affected by sql injections. But the contents are different as follows
western union india belgaum
western union india bolegaon
western union india barhaj
western union india budhana
western union india belda
western... (6 Replies)
I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation?
Here is my query:
cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}'
02:00:00... (1 Reply)
I have one requirement to delete all lines from a file if it matches below scenario. File contains three column. Employee Number, Employee Name and Employee ID
Scenario is: delete all line if Employee Number (1st column) contains below
1. Non-numeric Employee Number
2. Employee Number that... (3 Replies)
I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :).
grep
grep -v -F -f targets.bed sort_list
grep -vFf sort_list targets
awk
awk -F, '
> FILENAME == ARGV {to_remove=1; next}
> ! ($5 in... (2 Replies)
I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: -->
cat comp.pkglist
Package list: nss-util-devel-3.28.4-1.el6_9.x86_64
Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
LEARN ABOUT PHP
mb_ereg_replace_callback
MB_EREG_REPLACE_CALLBACK(3) 1 MB_EREG_REPLACE_CALLBACK(3)mb_ereg_replace_callback - Perform a regular expresssion seach and replace with multibyte support using a callbackSYNOPSIS
string mb_ereg_replace_callback (string $pattern, callable $callback, string $string, [string $option = "msr"])
DESCRIPTION
Scans $string for matches to $pattern, then replaces the matched text with the output of $callback function.
The behavior of this function is almost identical to mb_ereg_replace(3), except for the fact that instead of $replacement parameter, one
should specify a $callback.
PARAMETERS
o $pattern
- The regular expression pattern. Multibyte characters may be used in $pattern.
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. You'll often need the $callback function for a mb_ereg_replace_callback(3) in just one place. In this case
you can use an anonymous function to declare the callback within the call to mb_ereg_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.
o $string
- The string being checked.
o $option
- Matching condition can be set by $option parameter. If i is specified for this parameter, the case will be ignored. If x is
specified, white space will be ignored. If m is specified, match will be executed in multiline mode and line break will be
included in '.'. If p is specified, match will be executed in POSIX mode, line break will be considered as normal character. Note
that e cannot be used for mb_ereg_replace_callback(3).
RETURN VALUES
The resultant string on success, or FALSE on error.
NOTES
Note
The internal encoding or the character encoding specified by mb_regex_encoding(3) will be used as the character encoding for this
function.
EXAMPLES
Example #1
mb_ereg_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 mb_ereg_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 #2
mb_ereg_replace_callback(3) using anonymous function supported in PHP 5.3.0 or later
<?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
";
echo mb_ereg_replace_callback(
"(d{2}/d{2}/)(d{4})",
function ($matches) {
return $matches[1].($matches[2]+1);
},
$text);
?>
SEE ALSO mb_regex_encoding(3), mb_ereg_replace(3), Anonymous functions, information about the callback type.
PHP Documentation Group MB_EREG_REPLACE_CALLBACK(3)