![]() |
#11 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Quick side-question... is it possible to make function in PHP of which an argument's not necessary? A function that'd be in the manual as function_name(int one, int two, [int three])
|
||
![]() ![]() |
|
![]() |
#12 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() What are you trying to do?
Code:
Replace [b] with <b>? |
||
![]() ![]() |
|
![]() |
#13 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Or str_replace(), but it wouldn't make sure each [*b*]'d have a [/*b*], which's another thing that needs to be checked and fixed.
|
||
![]() ![]() |
|
![]() |
#14 | ||
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2004
Location: Jan Mayen, Svalbard and Jan Mayen
Posts: 2,167
|
![]() uhm
Code:
function blah($arg1, $arg2=10) { blah(10) and blah(10,20)
__________________
Flowing with the stream of life |
||
![]() ![]() |
|
![]() |
#15 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() Then in reg. expression, you have to check for this:
'(\[b\])?(\[\/b\])' or something like that. So, you're looking for regular expression that in one line has both opening and closing tag, and use replace function to fix it. I'm not sure if ? will work for all characters between, data might be able to tell you that. (or just check reference on the page you posted above) When you are done, check for tags that have no matching opening/closing tag. |
||
![]() ![]() |
|
![]() |
#16 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Location: ,
Posts: 113
|
![]() Quote:
Code:
/\[b\](.*?)\[\/b\]/ig If you're trying to write a forgiving BBCode parser and aren't just learning regexp then you're going about things all wrong. Regular expressions are for matching patterns, not for constructing push-down automata. Keep in mind that there's nesting and nesting requirements which regular expressions just can't handle well (it's possible with things like look-ahead and look-behind matching, but it's not pretty, it's not fast, and it's not reliable). |
||
![]() ![]() |
|
![]() |
#17 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() How do you suggest I'd go 'bout it then?
|
||
![]() ![]() |
|
![]() |
#18 | ||
![]() ![]() ![]() Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
![]() Quote:
|
||
![]() ![]() |
|
![]() |
#19 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Location: ,
Posts: 113
|
![]() Quote:
<!--QuoteBegin-plix Regular expressions are for matching patterns, not for constructing push-down automata.[/quote] Use a push-down automaton (a finite state machine doesn't include a stack, which is necessary to do open- and close-tag matching. It's a bit harder to implement if you haven't written one before, but it's not only easier to maintain, it's much more flexible. |
||
![]() ![]() |
|
![]() |
#20 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Hmmm... I've never heard of a push-down automaton. I'll see if I can find a tutorial 'bout it
|
||
![]() ![]() |
|
![]() |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
regular | sgtboat | Blah, blah, blah... | 4 | 26-11-2008 03:30 AM |
When will regular updates start? | Doink | Blah, blah, blah... | 6 | 13-12-2007 10:00 AM |
|
|
||
  |