S Sofian Member Apr 10, 2023 #1 I have create text with BBCodeView, sample : Code: Copy [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 ?
I have create text with BBCodeView, sample : Code: Copy [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 ?
J Juanet Member Licensed User Longtime User Apr 10, 2023 #2 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: Copy 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
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: Copy 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, "")
S Sofian Member Apr 10, 2023 #3 Juanet said: 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: Copy 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, "") Click to expand... thanks, its works perfect. Upvote 0
Juanet said: 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: Copy 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, "") Click to expand... thanks, its works perfect.
Erel B4X founder Staff member Licensed User Longtime User Apr 11, 2023 #4 1, 2 are not needed for many years now. Use Regex.Replace instead. Upvote 0
S Sofian Member Apr 11, 2023 #5 Erel said: 1, 2 are not needed for many years now. Use Regex.Replace instead. Click to expand... sample code to implement please Upvote 0
Erel said: 1, 2 are not needed for many years now. Use Regex.Replace instead. Click to expand... sample code to implement please