Dynamic text for SO10 texts in SapScript - sapscript

Im trying to change some texts in SO10. I´d like to check a variable and (depending on the result) would like to use different lines of the text.
Is it possible to use:
/: IF &variable& is initial.
** Text1
/: ELSE.
** Text2
/: ENDIF.
in SO10-texts?
The Variable contains the users mobile number but isn´t filled for all users.

I was able to solve the problem by "escaping" the part of text i wanted to hide. By setting '& text 'VARIABLE& the part of the text is only displayed, if the variable is filled.

Related

How do I use regex to return text following specific prefixes?

I'm using an application called Firemon which uses regex to pull text out of various fields. I'm unsure what specific version of regex it uses, I can't find a reference to this in the documentation.
My raw text will always be in the following format:
CM: 12345
APP: App Name
BZU: Dept Name
REQ: First Last
JST: Text text text text.
CM will always be an integer, JST will be sentence that may span multiple lines, and the other fields will be strings that consist of 1-2 words - and there's always a return after each section.
The application, Firemon, has me create a regex entry for each field. Something simple that looks for each prefix and then a return should work, because I return after each value. I've tried several variations, such as "BZU:\s*(.*)", but can't seem to find something that works.
EDIT: To be clear I'm trying to get the value after each prefix. Firemon has a section for each field. "APP" for example is a field. I need a regex example to find "APP:" and return the text after it. So something as simple as regex that identifies "APP:", and grabs everything after the : and before the return would probably work.
You can use (?=\w+ )(.*)
Positive lookahead will remove prefix and space character from match groups and you will in each match get text after space.
I am a little late to the game, but maybe this is still an issue.
In the more recent versions of FireMon, sample regexes are provided. For instance:
jst:\s*([^;]?)\s;
will match on:
jst:anything in here;
and result in
anything in here

How can I find a string in a cell containing a link?

I have some cells in openoffice calc which contain links/URLs. They display, of course, in calc as text, and hovering the mouse shows the URL. Clicking on those cells brings up the URL referenced.
I want to match a string in the displayed text. The below shows the spreadsheet:
spreadsheet
Cell A1 contains the string searched for.
Cells A4:A7 contain the links/URLs.
Cells B4:B7 are copies of A4:A7 but with Default format to remove the link/URLs. Cell B3 contains my match formula, which successfully finds the string in B4:B7.
I've tried the following in cell A3 to find the string in A4:A7
`=MATCH("^"&A1&".*";B4:B7;0)` #only works on the default formatted cells.
`=MATCH(".*"&A1&".*";A4:A7;0)` #
`=MATCH(A1&".*";A4:A7;0)` #
`=MATCH(A1;A4:A7;0)` #
Also, tried several other regular expressions, none of which work. Yes, I'm rusty on regex's, but what am I doing wrong? Or, is the literal string actually not present in the search field unless I change the format?
All the problems with the searches were caused by the fact that
'Search criteria = and <> must apply to whole cells'
was enabled in Tools->Options->Openoffice Calc->Calculate.
Turning this setting off makes everything work as advertised. The clue was that the regex ".*"&A1&".*", which of course matches a full line of plain text, worked with the range B4:B7.
The simplest solution is the expression:
=MATCH(""&A1;A4:A7;0) # "" invoked to trigger regex

Trying to select all text except for Twitter handle in Regex

I've exhausted everything I could find and just can't seem to get this to work. I have a .txt with rows of Twitter posts and I'm trying to delete everything but the #handles mentioned in the text.
For example:
Row1: This is the text of the tweet #Handle1
Row2: This text is meant for #Handle2 and #Handle3
Would result in:
Row1: #Handle1
Row2: #Handle2 #Handle3
I've come up with a regex expression to select the handles as: #[^\W]*
That works for all the handles in the set even if they have a colon or period immediately after them without a space (happens often).
I tried adding the negative lookahead command to it: (?!(#[^\W]*))
But I don't really know what else to add to make it work?
Thanks!
So you can loop through each row, and scan for the twitter handles.
For example,
str = "This text is meant for #Handle2 and #Handle3"
str.scan(/#\w+/).to_a #=> ["#Handle2", "#Handle3"]
Then you can manipulate the array however you want.
the \w is any alphanumeric and underscore character, you can modify that if you need any other characters.

RegEX: Matching everything but a specific value

How do i match everything in an html response but this piece of text
"signed_request" value="The signed_request is placed here"
The fast solution is:
^(.*?)"signed_request" value="The signed_request is placed here"(.*)$
If value can be random text you could do:
^(.*?)"signed_request" value="[^"]*"(.*)$
This will generate two groups that.
If the result was not successful the text does not contain the word.
If the text contains the text more than once, it is only the first time that is ignored.
If you need to remove all instances of the text you can just as well use a replace string method.
But usually it is a bad idea to use regex on html.

Trimming text from a multi-line entry in postgres with regex

I have a column "verbatim" where each entry contains multiple lines. Here's an example:
Dummy field1:Text
Tell Us More:Text to capture
Dummy field2:Text
I'd like to capture only Text to capture text in the second line Tell Us More: and put that value into the column verbatim_scrubbed. In the example above, Text to capture would be the entry in verbatim_scrubbed.
I'm not that great with postgres and regexp, so I was hoping somebody could help me out here. Was thinking of something similar to the following:
update TABLE
set verbatim_trimmed = array_to_string(regexp_matches(verbatim,'tell us more:(.*)','gi'));
This doesn't work, but I have a feeling something similar may work.
Perhaps there is a direct way to capture the: Text to capture without the cariage return \r and the new line \n charracters (without using the regexp_replace).
Here is what you can do:
select regexp_replace(array_to_string(regexp_matches(verbatim, '^Tell Us More:(.*)$','n'),'',''), E'[\\r\\n]', '' ) from my_table;