Parse Email Address - Substring

#1

In a transform file I need to parse the email address. In the c3typ file I have this code.

userName: ~ expression ‘lowerCase(username).substring(0, username.indexOf("@"))’

When I provision I get the following error message:

Wrong number of function arguments for function substring at 1:0 in lowerCase(username).substring(0, username.indexOf("@"))"

Does this type of coding need to be done in a .js file?

0 Likes

#2

substring requires 3 arguments as you can check in the documentation with c3ShowFunc(ExpressionEngineFunction, 'substring')

substring(str, start, end): string
0 Likes

#3

You could try using the split function instead?

ExpressionEngineFunction.split

1 Like