-3

I need to hide ellipsis element (so basically three dots ...) that starts every text in paragraph.

So e.g. text goes like '...some text' so how do I trim the ... at the beginning and it shows only 'some text'?

Looking for CSS or JS solution.

There's not much of a code, just simple HTML:

<p>... Some text rendered by some PHP CMS</p>

so what I want is that it would hide all starting ellipsis:

<p>Some text rendered by some PHP CMS</p>

It's not duplicate, I here ask for how to hide the ellipsis, not add it. It doesn't have to be ellipsis, I need somehow hide the three characters starting the paragraph which in this case are '...'.

Optimus Prime
  • 499
  • 3
  • 8
  • 18

2 Answers2

1

Use a regex replace. Match any number of dots that your string begins with and replace them by an empty string ""

For Example : "...my string".replace(/^\.*/, ""); will become "my string"

Rahul Shardha
  • 399
  • 7
  • 16
edhedges
  • 2,722
  • 2
  • 28
  • 61
  • 1
    Won't this replace ALL `.` in the string as compared to only the first 3? – Rahul Shardha Jun 25 '14 at 20:27
  • @ThePlatypus You are correct I'll edit my answer. – edhedges Jun 25 '14 at 20:27
  • 1
    How's this : `/^\.*/` ? This would take care of the any number of `.`s at the beginning of the string rather than a concrete 3. I can't add an answer 'cause it's a duplicate. – Rahul Shardha Jun 25 '14 at 20:32
  • So there would be multiple paragraphs that has starting ellipsis and the my string part is always different text. Maybe it would work better if you included somehow the starting paragraph tag like "

    ..." and then just replace it with "

    "?

    – Optimus Prime Jun 25 '14 at 20:33
  • 1
    @OptimusPrime Getting the text in the element isn't part of the question. Once you have that text store it in a var and call `.replace` on it. – edhedges Jun 25 '14 at 20:34
0

You could do a string replace like here:

var str = "...some text";
var res = str.replace("...", "");
Rick Burns
  • 1,538
  • 16
  • 20