1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Having Difficulty with BB Option Match Regular Expression

Discussion in 'Troubleshooting and Problems' started by Eoj Nawoh, Jul 28, 2016.

  1. Eoj Nawoh

    Eoj Nawoh Active Member

    Hello,

    Please forgive me if I'm missing something. I have made a custom BB Code that is supposed to only accept numbers.

    For instance, you'll put something like [mycode]1023982323[/mycode] and it takes that number and uses it for a HTML class.

    Whoever, there seems to be an issue in that, I'm unable to get regex to only allow numbers under Custom BB Code.

    Currently my Option Match Regular Expression has:
    (/\d+/) and I've also tried /\d+/

    Neither of these worked. I will be honest, I have very little familiarity with regex for PCRE.

    Would anyone be able to help me with this?
     
    Last edited: Jul 29, 2016
  2. Mike

    Mike XenForo Developer Staff Member

    The matching here is specifically for the {option} part, not the {text} part. If you need to do text-part validation, it has to be done in a callback. (There isn't any parse-time matching of that.)
     
  3. Eoj Nawoh

    Eoj Nawoh Active Member

    Alright, that explains a lot! Thank you.
     
  4. Eoj Nawoh

    Eoj Nawoh Active Member

    Question, if I made the {option} be the number, and just had text work. Would the regex and BB code work then?
     
  5. Mike

    Mike XenForo Developer Staff Member

    As in:
    Code:
    [mycode=1234]...[/mycode]
    If you approach it like that, then you can specify a regex. You likely want:
    Code:
    /^\d+$/
    As the regex.
     
  6. Eoj Nawoh

    Eoj Nawoh Active Member

    Alright, thank you for the help, that worked.
     

Share This Page