Looking for a pattern


#1

I am looking for a pattern to match the last underline and its following
string with “####”. for example,

“abc_def_ghi” => “abc_def####”

If I use _.* as the pattern it will replace begin with the first
underline. Which pattern is suite for this case?

thanks.


#2

Zhao Yi wrote:

I am looking for a pattern to match the last underline and its following
string with “####”. for example,

“abc_def_ghi” => “abc_def####”

“abc_def_ghi”.match(/[^]*$/)

That should do the trick, shouldn’t it?

H!


#3

Harald Eilertsen wrote:

Zhao Yi wrote:

I am looking for a pattern to match the last underline and its following
string with “####”. for example,

“abc_def_ghi” => “abc_def####”

“abc_def_ghi”.match(/[^]*$/)

That should do the trick, shouldn’t it?

H!

Yes, very good. thanks.