Jump to content

Almost there...


RaythMistwalker

Recommended Posts

Ok i have this as bbcode regex:

    $bbreplace = array (
        "/\[b\](.*?)\[\/b\]/is" => "<b>$1</b>",
        "/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",
        "/\[url\=(.*?)\](.*?)\[\/url\]/is" => "<a href='$1'>$2</a>",
        "/\[img\]http://(.*?)\[\/img\]/is" => "<img src='$1'>",
        "/\[s\](.*?)\[\/s\]/is" => "<s>$1</s>",
        "/\[i\](.*?)\[\/i\]/is" => "<i>$1</i>",
        "/\[color=(.*?)\](.*?)\[\/color\]/is" => "<font color='$1'>$2</font>",
        "/\[size=(.*?)\](.*?)\[\/size\]/is" => "<font size='$1'>$2</font>",
        "/\[list\](.*?)\[\/list\]/is" => "<ul>$1</ul>",
        "/\[list=1\](.*?)\[\/list\]/is" => "<ol>$1</ol>",
        "/\[\*\](.*?)/i" => "<li>$1</li>"
        );
      $PostText = preg_replace(array_keys($bbreplace), array_values($bbreplace), $PostText);

 

Now, this works PERFECTLY apart from 1 thing.

If I use the [ list] then [ *] it does it like so:

 

wtf.png

 

 

Any ideas?

 

Edit: I have checked multiple skins and it isn't a skin issue.

Link to comment
Share on other sites

What are quantifiers?

 

And I apologize but I never even realized that was against the rules since I had literally just deleted about 10 PM's recieved a year ago where people were asking me for help. But it is slightly frustrating when I request help on a forum where usually I get help no problem, and no one even bothers to reply when I get the same problem for a week+ straight.

Link to comment
Share on other sites

You can get an automated response to questions like that using tools like Google. You don't need someone to give the answer to you.

 

This is a forum for self-made code. We're not here to adjust your copied code to work properly.

If you produced that wall of RegEx up there, you'd know what a quantifier was, or the name would at least be familiar. If you can't find the quantifier in

/\[\*\](.*?)/i

, I do not believe you wrote it.

 

BTW - You are not entitled to help - you are entitled to ask for help. If you get it, then be appreciative. If you don't, and others around you are, perhaps there's an issue with your question. Please don't become frustrated if your thread gets ignored.

Link to comment
Share on other sites

No, you tried to modify someone's code you didn't fully understand. If you understood, you wouldn't need help with such a minor issue.

 

That's why I'm not just giving you solution now - when you try and modify that, you'll end up back here when something doesn't work.

Link to comment
Share on other sites

perhaps there's an issue with your question. Please don't become frustrated if your thread gets ignored.

:qft:

 

We have stickies for a reason.  Contrary to the belief of some people, they are not there so that we can be assholes on power trips.  They are there because we know from a lot of experience trying to help people that we need certain info in order to help with a problem, and that usually when a person asks for help, they rarely know how to even ask for that help. 

 

It's kind of hard to know what the problem really is when you didn't properly explain the problem in the first place.  You show your regex, which is good.  But then you point at two of the array entries and show a picture of a list.  You did not explain what the problem actually is.  My best guess is that you're saying the bullet points aren't lined up properly but it's only a guess.  You failed to show the subject, the content you are trying to perform the regex on.  Nor did you show what the preg_replaces are doing vs. what you want it do.  Also, if the issue is that the bullets aren't lined up properly, it's probably not even a regex issue, but a styling issue (css).

 

 

 

 

 

Link to comment
Share on other sites

The issue is the values are being echo'ed outside of the <li></li> tags. This is because he's used a lazy quantifier at the end of his RegEx. If you haven't told the RegEx to match something after a lazy quantifier, it won't match anything. That's how it works :P

 

His biggest issue was wondering why it was outputting improperly without viewing the source of the page.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.