Drupal 8 Rules module - How to configure Rules module to send email notification for every comment posted
Introduction In our previous post, where we saw How to configure comments module…
May 14, 2019
This post some useful tips of using strings, and some issues while dealing with strings
Hope, you have seen Python string format
to_search = 'my_name'
my_var = 'my_name_is_gorav'
if my_var.startswith(to_search):
print('Found')
Example, you have a string:
my_var = 'Name:GyanBlog'
You want to have anything after colon
name = my_var.split(':')[1]
Example: You have some long string like:
name = 'SERVICE_CLOUD_ACCOUNTS'
And, I want something like:
ServiceCloudAccounts
Then, use this code:
new_name = name.title().replace('_', '')
title() method will give you Service_Cloud_Accounts, then we have to remove any other characters we want
my_str.strip()
Your string has multiple spaces in between, and you want to convert them into one only.
import re
s = 'hey, i have multiple spaces'
re.sub("\s+", " ", s);
# Output
'hey, i have multiple spaces'
It works perfectly find with following cases
print('{hi}')
print('{hi} %s' %('hi'))
But, not with
website='GyanBlog.com'
print(f'hi { {website} .com}')
You have to use Double Curly-braces
website='GyanBlog.com'
{% raw %}
print(f'hi {{ {website} .com}}')
{% endraw %}
s = 'GyanBlog'
s[1:]
#Output: yanBlog
s = 'GyanBlog'
s[:-1]
Introduction In our previous post, where we saw How to configure comments module…
Introduction In last post, we saw How to read CSV with Headers into Dictionary…
You are developing a nodejs web application having some UI and backend APIs…
Static websites have several advantages over dyanamic websites. If you are…
Introduction I got my seo backlink work done from a freelancer. It was like 300…
Introduction In this tutorial we will see: How to instantiate different classes…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…