0

I am looking for a way to hide words in a string via their position so reg ex will not work. Is there a easy way as I do not have access to the template files so I can not alter span wrapping or add classes ect to the document.

I would like to hide the "by Salutions" text. This text will change to who the author is so as I said regular expressions will not work, but the position of the words will be identical.

Here is a snippet in question.

<p class="p-meta"><span>In <a href="http://www.domain here" title="View all posts in: &ldquo;People&rdquo;"> People</a> by Salutions</span><span><time class="entry-date" datetime="2014-12-05T13:01:18+00:00">December 5, 2014</time></span></p>

Thanks for your time!

3
  • 3
    "text will change to who the author is so as I said regular expressions will not work" that's exactly what regular expressions are good at Commented Jan 20, 2015 at 12:02
  • I will have over 30 different names posting articles, also the names will change frequently that's why I was thinking against reg ex. Commented Jan 20, 2015 at 12:09
  • @OP - That makes no sense, you don't need to specify each author, regular expressions have wildcards for a reason. Commented Jan 20, 2015 at 12:13

2 Answers 2

1

If always at same index, you can use:

$('p.p-meta span:first').contents().eq(2).remove();

-DEMO-

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

Comments

0

Here's my solution to adding dynamically an author's name:

<p class="p-meta">
    <span>In 
        <a href="http://www.domain here" title="View all posts in: &ldquo;People&rdquo;"> 
            People
        </a> by <span id="owner"></span>
    </span>
    <span>
        <time class="entry-date" datetime="2014-12-05T13:01:18+00:00">
            December 5, 2014</time>
    </span>
</p>

By using this function, the author's name would be added to that HTML:

function addOwner(owner) {
    $( '#owner' ).text( owner );
}

I've created a JSFiddle.

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.