How to get text after the match REGEX

I have string "my home" and regex: $reg = "/hom/" for example. I'm struggling to find out how can I get text after the match (until the end of word), in this case I'm looking for 'e'.

Another example:

$string = 'soulful'; $reg = '/soul/';

=>>> I need 'ful'. Thank you in advance.

Answers


You can use:

$str = 'soulful';
$reg = '/soul(\w+)/';
if ( preg_match($reg, $str, $m) )
   print_r ($m);
OUTPUT
Array
(
    [0] => soulful
    [1] => ful
)

Need Your Help

Bad OOP to have lots of classes with only 1 or 2 methods

oop design-patterns

Is it a sign of bad design where you have lots of classes with only 1 or 2 methods in them?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.