Editing template variables using regularExpression()

I'm building a template for web components whose class names should depend on the file name. In practice:

prefix-component-name.tsx

should return

ComponentName

Now, I was able to return the desired component name including the prefix with the following expression:

capitalize(camelCase(fileNameWithoutExtension()))

I though in order to strip the prefix I could use a regular expression:

regularExpression(camelCase(fileNameWithoutExtension()), ^.+[-], "")

However, it obviously didn't work. I couldn't find any example about regularExpression(String, Pattern, Replacement) usage in the docs. Any help please?

2 comments

Thank you @Elena!

I had to wrap the pattern in quotes to make it work: 

capitalize(camelCase(regularExpression(fileNameWithoutExtension(), "^[^-]*-", "")))

 

1

Please sign in to leave a comment.