# Parsing BBCode and setting "currentSelection" issues

**URL:** <https://forum.kirupa.com/t/parsing-bbcode-and-setting-currentselection-issues/318018>\
**Category:** flash\
**Created:** [January 8, 2011, 8:29am UTC](https://forum.kirupa.com/t/parsing-bbcode-and-setting-currentselection-issues/318018 "2011-01-08T08:29:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IQAndreas](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@IQAndreas](https://forum.kirupa.com/u/IQAndreas)\
**Post date:** [January 8, 2011, 8:29am UTC](https://forum.kirupa.com/t/parsing-bbcode-and-setting-currentselection-issues/318018/1 "2011-01-08T08:29:20Z")

</div>

[SIZE=1]First I’d like to make it clear that I haven’t started developing anything yet. This is just a “potential roadblock” that I’m tossing around in my mind. This is not time-critical, and knowing me, I may not even get around to finishing it anyway. Still, it’s a problem that must be solved.[/SIZE]

Let’s say you have a class which converts BBCode to AS3-friendly html and displays that formatted text in an AS3 TextField.

If the user selects a region of the formatted text (which gives a “selectionBeginIndex” and “selectionEndIndex”), how would one efficiently “map” that selection back to the BBCode? Since any BBCode within the text may offset the selection indexes.
