m (formatting) |
|||
Line 9: | Line 9: | ||
===Replace parts or whole text in target widget with content=== | ===Replace parts or whole text in target widget with content=== | ||
− | ;<code>[gn:act_replaceText]|[target,sourcePattern,sourceReplacementContent]</code> | + | :;<code>[gn:act_replaceText]|[target,sourcePattern,sourceReplacementContent]</code> |
− | {| class="wikitable sortable" style="font-size: 85%; text-align: left;" | + | :{| class="wikitable sortable" style="font-size: 85%; text-align: left;" |
|- | |- | ||
! scope="col" | Parameter | ! scope="col" | Parameter | ||
! scope="col" | Description | ! scope="col" | Description | ||
|- | |- | ||
− | | [[target]] | + | | <code>[[target]]</code> |
− | | [[target]] | + | | [[target]] on which text replacement will be performed |
* Valid [[target|targets]]: | * Valid [[target|targets]]: | ||
− | :*[[Datatypes#text|text]] | + | :*<code>[[Datatypes#text|text]]</code> |
|- | |- | ||
− | | [[source|sourcePattern]] | + | | <code>[[source|sourcePattern]]</code> |
− | | | + | | source of pattern for text replacement. Use [https://en.wikipedia.org/wiki/Regular_expression regular expression], with [http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html pattern]. |
* Valid [[source|source]]: | * Valid [[source|source]]: | ||
− | :*[[Datatypes#text|text]] | + | :*<code>[[Datatypes#text|text]]</code> |
|- | |- | ||
− | | [[source|sourceReplacementContent]] | + | | <code>[[source|sourceReplacementContent]]</code> |
− | | | + | | source of replacement content for text replacement |
* Valid [[source|source]]: | * Valid [[source|source]]: | ||
− | :*[[Datatypes#text|text]] | + | :*<code>[[Datatypes#text|text]]</code> |
|- | |- | ||
|} | |} | ||
Line 36: | Line 36: | ||
=====initial value===== | =====initial value===== | ||
− | <code>@variable/test</code> = <code>name.surname@domain.com</code> | + | :<code>@variable/test</code> = <code>name.surname@domain.com</code> |
=====variables.xml===== | =====variables.xml===== | ||
Line 60: | Line 60: | ||
=====after action execution===== | =====after action execution===== | ||
− | <code>@variable/test</code> = <code>name_surname_domain_com</code> | + | :<code>@variable/test</code> = <code>name_surname_domain_com</code> |
<hr> | <hr> |
Latest revision as of 19:59, 12 July 2017
gn:act_replaceText
- Description
- Action is used to replace text by regular expression pattern and to store it again to target
- Action returns
- void
Action signatures
Replace parts or whole text in target widget with content
[gn:act_replaceText]|[target,sourcePattern,sourceReplacementContent]
Parameter Description target
target on which text replacement will be performed - Valid targets:
sourcePattern
source of pattern for text replacement. Use regular expression, with pattern. - Valid source:
sourceReplacementContent
source of replacement content for text replacement - Valid source:
Example
initial value
@variable/test
=name.surname@domain.com
variables.xml
<variable id="test" type="string"/>
strings.xml
<string name="pattern">@|\.</string> <string name="replacementString">_</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_replaceText]|[@variable/test,@string/pattern,@string/replacementString]" />
after action execution
@variable/test
=name_surname_domain_com