Hi All,
I have a requirement, have to separate the string with a Hyphen(-) after every 4th character entered by the use, also it should not count space as string and should ignore it.
Discussion posts and replies are publicly visible
If you have the regular expressions plug-in, you could try...
load( local!example, a!textField( value: local!example, saveInto: a!save( local!example, joinarray(regexallmatches("....|.*", stripwith(save!value, " -")), "-") ) ))
insert("2345987611112222", "-", {5,9,13,}) Run this in "Try it now" box on any function documentation page. This should be a good start. You can use stripwith() to remove the spaces, or anything else you don't want. The stripwith function with your text input as it's first parameter will replace "2345987611112222"
Advantages over others: You don't need a plugin and it's only 1 line of code.
Hi Kumar,
You can create an expression rule with below code and use it:
with( local!insertIndex: 4, /*"Insert Hyphen after every 4th character in input."*/ if(isnull(ri!text), null, joinarray( char( insert( code( ri!text ), 45, /* To Insert Hyphen */ ( ( enumerate( quotient( len( ri!text ), local!insertIndex ) ) + 1 ) * local!insertIndex ) + 1 ) ) ) ) )