I would like to highlight a particular word-pattern either individually, within or end of string in b4A
For example:
The pattern 'rail' should be highlighted in red colour in the sentence 'Railway tracks are made of iron. The rail ran over the dog and its entrails came out'.
The sequence of letters marked in 'underline' should be highlighted in the above example.
i) What is the regex expression to match this pattern and how should the word be highlighted ?
CSBuilder is supported by B4A and B4J. There are some differences in the supported properties. A more powerful cross platform alternative: [B4X] BCTextEngine / BBCodeView - Text engine + BBCode parser + Rich Text View This sub searches for matches and uses CSBuilder to mark the matches...
CSBuilder is supported by B4A and B4J. There are some differences in the supported properties. A more powerful cross platform alternative: [B4X] BCTextEngine / BBCodeView - Text engine + BBCode parser + Rich Text View This sub searches for matches and uses CSBuilder to mark the matches...
Sorry... But I am unable to make it work... Attaching the source code ... I am getting the following error. Also pasted your calling code example string.
Please help.
Thanks..
:BEGIN ERROR:
Logger connected to: ......
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_markpattern (java line: 422)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at java.util.regex.Matcher.start(Matcher.java:1159)
at anywheresoftware.b4a.keywords.Regex$MatcherWrapper.GetStart(Regex.java:174)
at b4a.example.main._markpattern(main.java:422)
at b4a.example.main._activity_create(main.java:367)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_markpattern (java line: 422)
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at java.util.regex.Matcher.start(Matcher.java:1159)
at anywheresoftware.b4a.keywords.Regex$MatcherWrapper.GetStart(Regex.java:174)
at b4a.example.main._markpattern(main.java:422)
at b4a.example.main._activity_create(main.java:367)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
In a regular expression, parentheses can be used to group regex tokens together and for creating backreferences. Backreferences allow you to reuse part of the regex match in the regex, or in the replacement text.