I'm trying to use the following command to do a batch find and replace in all commonly named files through a file hierarchy
find . -name 'file' |xargs perl -pi -e 's/find/replace/g'
which works fine except for a substitution involving parenthesis.
As a specific example I'm trying to sub... (3 Replies)
Hi
I would like to replace a comma in parentheses to a semicolon for example. Other commas outside () stay unchanged. How can I do this?
aaaa,bbb,ccc,ddd(eee,fff,ggg),hhh,iii
to
aaaa,bbb,ccc,ddd(eee;fff;ggg),hhh,iii
Thanks (5 Replies)
Hello All,
I have a string "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031", and I just want to extract LLSV1, but I dont get the expected result when using the sed command below.
# echo "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031" | awk '{print... (4 Replies)
This is my first post, please be nice. I have tried to google and read different tutorials.
The task at hand is:
Input file input.txt (example)
abc123defhij-E-1234jslo
456ujs-W-abXjklp
From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Hi,
I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file.
For Example:
If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained.
But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
HI Folks,
I'm looking for a solution for this issue.
I want to find the Pattern 0/ and replace it with /. I'm just removing the leading zero. I can find the Pattern but it always puts literal value as a replacement.
What am I missing??
sed -e s/0\//\//g File1 > File2
edit by... (3 Replies)
Hi
I know sed and awk has options to give range of line numbers, but
I need to replace pattern in specific lines
Something like
sed -e '1s,14s,26s/pattern/new pattern/' file name
Can somebody help me in this....
I am fine with see/awk/perl
Thank you in advance (9 Replies)
I have a sample text format as given below
<Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text>
<Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
Hello Everyone,
I have many files like so:
file1.txt
file2.txt
file3.txt
Within each file I have many lines of random text separated by commas like so:
abcAAA,123,defAA,456777,ghiA,789
jklB,101,mnoBBB,11211,pqrB,13111
stuCC,415,vwxCCCC,161,yzaC,718
I am trying to use SED or AWK to... (4 Replies)
Discussion started by: D3U5X
4 Replies
LEARN ABOUT PHP
is_subclass_of
IS_SUBCLASS_OF(3) 1 IS_SUBCLASS_OF(3)is_subclass_of - Checks if the object has this class as one of its parentsSYNOPSIS
bool is_subclass_of TRUE (mixed $object, string $class_name, [bool $allow_string])
DESCRIPTION
Checks if the given $object has the class $class_name as one of its parents.
PARAMETERS
o $object
- A class name or an object instance. No error is generated if the class does not exist.
o $class_name
- The class name
o $allow_string
- If this parameter set to false, string class name as $object is not allowed. This also prevents from calling autoloader if the
class doesn't exist.
RETURN VALUES
This function returns TRUE if the object $object, belongs to a class which is a subclass of $class_name, FALSE otherwise.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.9 | |
| | |
| | Added $allow_string parameter |
| | |
| 5.3.7 | |
| | |
| | Added support for $class_name to work with |
| | interfaces |
| | |
| 5.0.3 | |
| | |
| | You may also specify the $object parameter as a |
| | string (the name of the class) |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
is_subclass_of(3) example
<?php
// define a class
class WidgetFactory
{
var $oink = 'moo';
}
// define a child class
class WidgetFactory_Child extends WidgetFactory
{
var $oink = 'oink';
}
// create a new object
$WF = new WidgetFactory();
$WFC = new WidgetFactory_Child();
if (is_subclass_of($WFC, 'WidgetFactory')) {
echo "yes, $WFC is a subclass of WidgetFactory
";
} else {
echo "no, $WFC is not a subclass of WidgetFactory
";
}
if (is_subclass_of($WF, 'WidgetFactory')) {
echo "yes, $WF is a subclass of WidgetFactory
";
} else {
echo "no, $WF is not a subclass of WidgetFactory
";
}
// usable only since PHP 5.0.3
if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) {
echo "yes, WidgetFactory_Child is a subclass of WidgetFactory
";
} else {
echo "no, WidgetFactory_Child is not a subclass of WidgetFactory
";
}
?>
The above example will output:
yes, $WFC is a subclass of WidgetFactory
no, $WF is not a subclass of WidgetFactory
yes, WidgetFactory_Child is a subclass of WidgetFactory
Example #2
is_subclass_of(3) using interface example
<?php
// Define the Interface
interface MyInterface
{
public function MyFunction();
}
// Define the class implementation of the interface
class MyClass implements MyInterface
{
public function MyFunction()
{
return "MyClass Implements MyInterface!";
}
}
// Instantiate the object
$my_object = new MyClass;
// Works since 5.3.7
// Test using the object instance of the class
if (is_subclass_of($my_object, 'MyInterface')) {
echo "Yes, $my_object is a subclass of MyInterface
";
} else {
echo "No, $my_object is not a subclass of MyInterface
";
}
// Test using a string of the class name
if (is_subclass_of('MyClass', 'MyInterface')) {
echo "Yes, MyClass is a subclass of MyInterface
";
} else {
echo "No, MyClass is not a subclass of MyInterface
";
}
?>
The above example will output:
Yes, $my_object is a subclass of MyInterface
Yes, MyClass is a subclass of MyInterface
NOTES
Note
Using this function will use any registered autoloaders if the class is not already known.
SEE ALSO get_class(3), get_parent_class(3), is_a(3), class_parents(3).
PHP Documentation Group IS_SUBCLASS_OF(3)