smozgur
BatCoder
- Joined
- Feb 28, 2002
- Messages
- 2,659
SLUGIFY function converts the given string to a URL slug.
We often use the document title as the page name to create a web page, which is called "URL slug". The document title often has invalid characters that cannot be used in the URL. Therefore, we generate a clean version of the title by replacing the invalid characters with a dash character. This function takes a given string and converts it to a URL slug by allowing only alphanumeric characters and dash.
This is a recursive function, and the second parameter is used as the loop counter.
We often use the document title as the page name to create a web page, which is called "URL slug". The document title often has invalid characters that cannot be used in the URL. Therefore, we generate a clean version of the title by replacing the invalid characters with a dash character. This function takes a given string and converts it to a URL slug by allowing only alphanumeric characters and dash.
This is a recursive function, and the second parameter is used as the loop counter.
Excel Formula:
=LAMBDA(reference, ndx,
IF(ndx > LEN(reference),
SUBSTITUTE(reference, "--", "-"),
SLUGIFY(
LET(
character, LOWER(MID(reference, ndx, 1)),
charcode, CODE(character),
LEFT(reference, ndx - 1) & IF(OR(AND(charcode > 96, charcode < 123), AND(charcode > 47, charcode < 58)), character, "-") & RIGHT(reference, LEN(reference) - ndx)
),
ndx + 1
)
)
)
SLUGIFY(reference, ndx) | ||||
---|---|---|---|---|
A | B | |||
1 | Article Title | URL Slug | ||
2 | Start Coding with Doctrine©2 ORM | start-coding-with-doctrine-2-orm | ||
3 | Searching in Online Book Catalog | searching-in-online-book-catalog | ||
4 | Pagination with Zend\Paginator | pagination-with-zend-paginator | ||
5 | Model Mapper Connected to Database Table - Zend\Db | model-mapper-connected-to-database-table--zend-db | ||
6 | Model●View●Controller (MVC) | model-view-controller-mvc- | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B6 | B2 | =SLUGIFY(A2,1) |
Upvote
0