Android Question How to get BBCodeView text without Tags

Sofian

Member
I have create text with BBCodeView, sample :
text1:
[Alignment=Justify][TextSize=15] [color=blue][b]THIS IS HEADLINE[/b][/color][/TextSize][/Alignment]

and it show perfect when apps runn. My question is how to get BBCodeView.text without tags format (plain text) from that sample result ?
 

Juanet

Member
Licensed User
Longtime User
1) Use Reflection

2) Get and copy the function "RegexReplace(Pattern As String, Text As String, Replacement As String) As String" from: https://www.b4x.com/android/forum/threads/regex-and-replace.15677/

3) Use regular expressions with this pattern: "\[[^\]]*\]"

Implementation:

B4X:
Dim  patternBBCode As String = "\[[^\]]*\]"

Dim textWithBBCode As String = "[Alignment=Justify][TextSize=15] [color=blue][b]THIS IS HEADLINE[/b][/color][/TextSize][/Alignment]"

Dim textClean As String = RegexReplace(patternBBCode, textWithBBCode, "")
 
Upvote 0

Sofian

Member
1) Use Reflection

2) Get and copy the function "RegexReplace(Pattern As String, Text As String, Replacement As String) As String" from: https://www.b4x.com/android/forum/threads/regex-and-replace.15677/

3) Use regular expressions with this pattern: "\[[^\]]*\]"

Implementation:

B4X:
Dim  patternBBCode As String = "\[[^\]]*\]"

Dim textWithBBCode As String = "[Alignment=Justify][TextSize=15] [color=blue][b]THIS IS HEADLINE[/b][/color][/TextSize][/Alignment]"

Dim textClean As String = RegexReplace(patternBBCode, textWithBBCode, "")
thanks, its works perfect.
 
Upvote 0
Top