MyBB Community Forums

Full Version: Jump -> Anchor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I was trying to create 2 MyCodes, [jump=anchorname][/jump] and [anchor=anchorname][/anchor]. However if I type [jump=there]Blabla[/jump] it doesn't replace with my HTML code. The same goes for Anchor.

Jump regex:

Jump replacement:
<a href="#$1">$2</a>

Anchor regex:

Anchor replacement:
<a name="$1" id="$1"></a>$2

What did I do wrong?

E: Nvm, feel free to use them.
Why did you place [A-Za-z0-9]+? You should make it (.*?) I guess.
([A-Za-z0-9]+) means that I only want to use alphanumeric characters for name, I don't think that's a problem. Anyways tried replacing it with (.*?) and still the same, it doesn't change to HTML replacement.
I see,

But still if you use $1 and $2 it refers to the first and second time you use (.*?), never seen codes such as ([A-Za-z0-9]+).
Not really, it refers to any value in () so it can be for example one char (A-Za-z).

Anyways I got them working without editing any code... So feel free to use them. I needed to delete and readd both. Weird bug.
How to apply?
i created two mycodes with Jump regex and Anchor regex but not work.

i tried
[jump= test]1. test [/jump][ test]1. test[anchor]

but not work.
please guide.
Depends on what you are trying to do with them. Here's a simplified version for internal links on a page (if you need links on other pages, then you'll need a slightly different regex)

Mycode (With Regular Expression):
\[jump=(\w+):(\w+)\]([\w ]+)\[/jump\]

(\w+) regex for one or more "word" characters [A-Za-z0-9_]
([\w ]+) regex for one or more "word characters [A-Za-z0-9_] and a space [ ]

Replacement code:
<a id="$1" href="#$2">$3</a>

The syntax to use it is as follows:
[jump=top:bottom]To the bottom[/jump]

top is what you name the jump point you are at (This can be any letters and/or with numbers / underscores).
bottom is the name of where you want to jump to again any letters and/or with numbers / underscores)
To the bottom is the text telling you where the link it destined, again lt's like the above, although it can contain spaces.

[jump=top:middle]to middle[/jump]
[jump=middle:bottom]to bottom[/jump]
[jump=bottom:top]to top[/jump]
Its very difficult to understand.
can anyone simply explain.

i need like below:
You need to add these in the relevant boxes on your Add New My Code page:
Admin > Configuration > MyCode > Add New My Code

Quote:Title: Jump
Description: Jump points to an anchor

Regular Expression:
\[jump=([A-Za-z0-9-+_]+)\]([A-Za-z0-9-+ _]+)\[/jump\]

<a href="#$1">$2</a>

Quote:Title: anchor
Description: anchors are pointed to by Jump

Regular Expression:

<a id="$1"></a>

Example of use of what you'd write in a post when these mycodes exist:
//Below is the anchors for contents:
[*][jump=syncope]SYNCOPE AND ANOXIC SEIZURES[/jump]
    [*][jump=Vasovagal]Vasovagal syncope[/jump]
    [*][jump=Reflex-anoxic]Reflex anoxic seizures[/jump]
    [*][jump=Breath-holding]Breath-holding attacks[/jump]

//Below the contents themselves:
//add your content for the header

[anchor=syncope][Size=6]SYNCOPE AND ANOXIC SEIZURES[/size]
//add your content for the header

[anchor=Vasovagal][Size=6]Vasovagal Syncope[/size]
//add your content for the header

[anchor=Reflex-anoxic][Size=6]Reflex anoxic seizures[/size]
//add your content for the header

[anchor=Breath-holding][Size=6]Breath-holding attacks[/size]
//add your content for the header

Hopefully the example is straight forwards enough.
I Think ,i am making somE mistake.
please check PM @stryderunknown
Pages: 1 2 3