Telegram Group & Telegram Channel
Converts a string to kebab case.

👉Use re.sub() to replace any - or _ with a space, using the regexp r"(_|-)+".

👉Use re.sub() to match all words in the string, str.lower() to lowercase them.

👉Finally, use str.join() to combine all word using - as the separator.

CODE:

from re import sub

def kebab(s):
return '-'.join(
sub(r"(\s|_|-)+"," ",
sub(r"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+",
lambda mo: ' ' + mo.group(0).lower(), s)).split())

Examples

kebab('camelCase') # 'camel-case'

kebab('some text') # 'some-text'

kebab('some-mixed_string With spaces_underscores-and-hyphens')
# 'some-mixed-string-with-spaces-underscores-and-hyphens'

kebab('AllThe-small Things') # 'all-the-small-things'

Share and Support
@Python_Codes



tg-me.com/python_codes/168
Create:
Last Update:

Converts a string to kebab case.

👉Use re.sub() to replace any - or _ with a space, using the regexp r"(_|-)+".

👉Use re.sub() to match all words in the string, str.lower() to lowercase them.

👉Finally, use str.join() to combine all word using - as the separator.

CODE:

from re import sub

def kebab(s):
return '-'.join(
sub(r"(\s|_|-)+"," ",
sub(r"[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+",
lambda mo: ' ' + mo.group(0).lower(), s)).split())

Examples

kebab('camelCase') # 'camel-case'

kebab('some text') # 'some-text'

kebab('some-mixed_string With spaces_underscores-and-hyphens')
# 'some-mixed-string-with-spaces-underscores-and-hyphens'

kebab('AllThe-small Things') # 'all-the-small-things'

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/168

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

That strategy is the acquisition of a value-priced company by a growth company. Using the growth company's higher-priced stock for the acquisition can produce outsized revenue and earnings growth. Even better is the use of cash, particularly in a growth period when financial aggressiveness is accepted and even positively viewed.he key public rationale behind this strategy is synergy - the 1+1=3 view. In many cases, synergy does occur and is valuable. However, in other cases, particularly as the strategy gains popularity, it doesn't. Joining two different organizations, workforces and cultures is a challenge. Simply putting two separate organizations together necessarily creates disruptions and conflicts that can undermine both operations.

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Python Codes from us


Telegram Python Codes
FROM USA