Results 1 to 10 of 51

Thread: ब्लॉग कोशिश कर रहा है بلاگز کی ک*Trying Blogs

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,316
    Rep Power
    10

    VBA Remove BB Code Code Tags in text

    VBA Remove BB Code Code Tags in text

    In the next post is a code to remove BB Code Code Tags in text

    This code is slightly redundant since I was given a simpler one ,
    http://www.eileenslounge.com/viewtop...202145#p202122
    which probably is more Full proof !
    But I include it here with description for future reference. I may use it in a following code or codes to cross check the results given.
    The code is intended to remove valid BB Code Code Tag sections from a Text string.
    In this case, valid means in terms of the syntax, which is basically as follows

    [TagWord=Some]Any text[/TagWord] or [B]Any text[/b]

    An arbitrary string is given initially in code section Rem 1)
    "gggg[d=fg]2[/d]45[/8]x[ddd[Cl=XYZ][/Cl][B]Any text[/b]"


    Then the main code is as follows

    Rem 2 Brief Code description
    The code works backwards 100 through the whole string. It looks at a character at a time.
    120 __ On If finding a ] , it notes the position of it,
    140 BcrdEEnd, then keeps going back.
    160___If it finds another it notes that as the ] position and carries on going back.
    170 It determines the position of a [ , BcrdESt, by looking for a [\
    It starts looking again for the next ] ,
    250 _____If a ] is found, it checks
    260 _____If the next character back is another ], Then it keeps going back. If the next character back was Not a ] , then the position of the ], BcrdSEnd, is
    270 noted
    A new last loop 290 starts going further back to look for a [
    300 ________If it finds a [ , it notes that, BcrdSSt.
    320 ________If in the unlikely event that it is a start of an end , like [\ then we have found a second End BB Code Code Tag so we do like_..
    BcrdEEnd = BcrdSEnd:
    BcrdESt = BcrdSSt:
    BcrdSEnd=0:
    ( BcrdSSt=0 )
    _..and go back and start again looking for the start tag. Otherwise the start position of the start tag, BcrdSSt, is noted, then it is finally time to go and think about getting rid of the code tag pair whose positions have now been determined....
    430 FkOffCrd:
    _..So I come to a point, aptly named, Rem 3) "I think we come here with a complete set of 4 positions". So I try to take the BB Code Code Tags out. As I am going backwards, the new string with the missing Code Tag pair does not mess up me going through the characters as I took off stuff “behind me”
    450 I overdo the use of variables here because I can and do, but also because a development of the code might be to look through a list of available BB Code Code Tags to check I have them . I do one quick validity check: I check that the word after the / in the End BB Code code tag is the same as the word in the start BB Code code tag ( that before an = , if there is an = ) . Only
    500____ If this condition ( which must be met for a valid BB Code code tag ) is met are the pair of tags removed by replacing them with , . Another condition is also checked: a / in second character of the stop tag.

    Either from going through a code section search with possible removal, or ,
    540 Else not , we are at the Next posCurrent of the main going backward Loop,
    580 , so keep going back looking for another, or a first possible start ( looking from the back ).
    Hopefully, for example at line 340, posCurrent would have been reduce to allow for the inner Loops going back in a code tag section search.


    _................................

    The code returns the string:
    gggg245[/8]x[ddd[B]Any text[/b]
    Last edited by DocAElstein; 02-11-2017 at 10:29 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •