XF 2.1 tag - replace to lowercase, whitespace with hyphen

-Eric-

New member
I would like to accept only a-z and 0-9 and hyphen.
Replace uppercase with lowercase, whitespace with hyphen, prevent accented letters.
typed "WINdows 10" replace to "windows-10"

in tag validation is this possible (and how)?
 

-Eric-

New member
someone?

Missing little for me to release the registration on my site.
Tag typing is very important, reducing similar words for better organization.
 

cwe

Member
The Content Tagging option in the ACP does have a field for "Tag match regular expression:" which could be used to restrict the allowed characters. I'm not a Regex wizard though, so I can't really give you the proper expression to use.
 

frm

Active member
The below will give you the desired effect on an "Instagram" level where you may not begin a tag with a number, nor can you begin or end it with any special characters (hyphen included). IE: this-tag works but -this-tag- doesn't, 2019-doesnt, year-2019 does.
^(?!^\W)^(?!^\d)(?!.[I][\W]$)[a-z0-9-][/I]$

Facebook allows numbers in the beginning, and if you're looking at software, this might be best as some software might be named 1-virus-removal (example) which wouldn't work with the above as it excludes the first character being a digit. If you want that, and like 2019-windows-update to work, use below:
^(?!^\W)(?!.*[\W]$)[a-z0-9-]*$

Stick your preference in ACP -> Setup -> Options -> Content tagging -> "Tag match regular expression:"
 

-Eric-

New member
thanks, but it didn't work.
Before creating this topic, I tried some RegEx.

I type TAG 1 and save it as tag 1 (default)
 

frm

Active member
thanks, but it didn't work.
Before creating this topic, I tried some RegEx.

I type TAG 1 and save it as tag 1 (default)
It will only apply to tags created after the regex is implemented. Previous tags will need to be edited.
 

frm

Active member
Oh, I get it. You want to convert WinDows-10 to windows-10.

That's not possible with the regex. It will only accept windows-10 and reject WinDows-10.

Probably need custom development.
 
Top