Keyword replacement


(Nick Papadatos) #1

Matrix Version: v5.3.4.2

I have the following condition which works but wanted to work out if using replace keywords would do the same thing:
Condition:
%begin_last_char:1491601%
%globals_get_name^escapehtml%’
%else_last_char:1491601%
%globals_get_name^escapehtml%'S
%end_last_char:1491601%

Essentially if a name ends with an ‘S’ then apply an apostrophe at the end else apply 'S
Can anyone tell/show me how the above can be used using the keyword modifiers or is it not possible?

Thanks in advance
NickyP


(Tim Davison) #2

Should be do-able. I’m not sure what the ‘last_char’ keyword is, I can’t find it in the online manuals, perhaps a custom condition defined in a paint layout? But I’m assuming it looks at the last char of GET param ‘name’. So you could simplify to something like this:

%globals_get_name%%globals_get_name^lastchars:1^lowercase^contains:s:':'s%

Basically first keyword just prints out the value. Then you call it again but just get the last character, ‘^lowercase’ so it’s a fair comparison, then mimic if/else behaviour with ‘^contains’. If the last char was an s, add an apostrophe, otherwise add apostrophe+s.

Unfortunately I don’t have access to a Matrix environment at the moment so can’t test it out for you.

Cheers


(Nick Papadatos) #3

Ok the condition is a Keyword Regexp Condition
Condition Is True If => The following keyword matches the specified pattern .
Keyword: %globals_get_name%
Pattern: [sS]$ [find upper or lowercase s]end of string

So if the name equals NICHOLAS, the result would be NICHOLAS’
If the names is NICK, the result would be NICK’S

Just gave that a go and that worked so many thanks Tim
Never gave a thought to call get_name twice, was trying to do it all within the one keyword modifier.
Regards