1

I have some Jquery code like this:

$("a[for_column="+ p_column_name +"]"

Problem is, when p_columns_name is something like this_table.user_name I need to remove everything before the . including the ..

Is this possible inline?

2
  • What about using Escape character / Commented Aug 14, 2015 at 8:51
  • 1
    p_column_name.substring(p_column_name.indexOf('.')+1). Commented Aug 14, 2015 at 8:53

2 Answers 2

2

Replace /.*\./ with nothing:

$("a[for_column="+ p_column_name.replace(/.*\./, '') +"]"

.* - everything before the last dot. \. - the dot itself.

Sign up to request clarification or add additional context in comments.

Comments

1

You do not neef any regex. Use indexOf with substring:

$("a[for_column="+ p_column_name.substring(p_column_name.indexOf('.')+1) +"]"

var p_column_name = "this_table.user_name";
alert(p_column_name.substring(p_column_name.indexOf('.')+1));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.