gn:act_getTextByRegex
- Description
- Action is used to get
text
value which can be a substring or entire value from source and store it into to a target.
- Action returns
- void
Action signatures
[gn:act_getTextByRegex]|[source,target,regex]
[gn:act_getTextByRegex]|[source,target,regex,matchNumber]
Parameter Description source
source from which value will be used. target
target to which "regexed" value will be stored. regex
target Regular expression pattern which is used on source value to extract whole or part of text value. (optional) matchNumber
matchNumber
number of match from which we want to extract text (in case there is more matches by regex pattern), by default first match will be returned (0) if this value is ommited. If number is bigger than count of matches that are returnednull
will be stored into target. If parameter is omitted value 0 is used.- Valid value:
- Integer numerical value, i.e. 1, 2,...10
- Valid value:
Example
initial target value
@variable/target
=
variables.xml
<variable id="textualSourceValue" type="text" defaultValue="">this is my text|with some other stuff|and some more stuff|which needs to be stored into somewhere|soome as other |</variable> <variable id="target" type="text" defaultValue=""></variable>
strings.xml
<string name="pattern">(.+?)\|</string>
screen.xml
<FrameLayout android:id="@+id/exampleFrame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" gn:act_set="[gn:act_getTextByRegex]|[@variable/textualSourceValue,@variable/target,@string/pattern,1]" />
after action execution target
@variable/target
=with some other stuff