bigfunctions > remove_strings
remove_strings¶
Call or Deploy remove_strings
?
✅ You can call this remove_strings
bigfunction directly from your Google Cloud Project (no install required).
- This
remove_strings
function is deployed inbigfunctions
GCP project in 39 datasets for all of the 39 BigQuery regions. You need to use the dataset in the same region as your datasets (otherwise you may have a function not found error). - Function is public, so it can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- You may prefer to deploy the BigFunction in your own project if you want to build and manage your own catalog of functions. This is particularly useful if you want to create private functions (for example calling your internal APIs). Discover the framework
Public BigFunctions Datasets:
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Description¶
Signature
remove_strings(string, strings_to_remove)
Description
Remove any string of strings_to_remove
from string
Examples¶
select bigfunctions.eu.remove_strings('I can eat candies', ['can', 'eat'])
select bigfunctions.us.remove_strings('I can eat candies', ['can', 'eat'])
select bigfunctions.europe_west1.remove_strings('I can eat candies', ['can', 'eat'])
+----------------+
| cleaned_string |
+----------------+
| I dies |
+----------------+
Need help using remove_strings
?
The community can help! Engage the conversation on Slack
For professional suppport, don't hesitate to chat with us.
Found a bug using remove_strings
?
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
For professional suppport, don't hesitate to chat with us.
Use cases¶
Let's say you have a dataset of product descriptions that are cluttered with promotional phrases like "Free Shipping!", "Limited Time Offer!", or "New Arrival!". You want to clean these descriptions to improve text analysis or create a more uniform presentation.
Here's how remove_strings
could be used:
SELECT product_id, bigfunctions.us.remove_strings(description, ['Free Shipping!', 'Limited Time Offer!', 'New Arrival!']) AS cleaned_description
FROM product_descriptions;
This query would process each row in the product_descriptions
table. For each product, the remove_strings
function would remove any occurrences of "Free Shipping!", "Limited Time Offer!", or "New Arrival!" from the description
field. The result would be stored in a new column called cleaned_description
.
Another example: Imagine you have user-generated comments and want to remove common spam words or phrases.
SELECT comment_id, bigfunctions.us.remove_strings(comment_text, ['[link removed]', 'click here', 'make money fast']) AS cleaned_comment
FROM user_comments;
This would remove instances of "[link removed]", "click here", and "make money fast" from the comment_text
, resulting in a cleaner cleaned_comment
field.
In essence, remove_strings
is helpful anytime you need to remove a specific set of strings from a larger body of text for cleaning, pre-processing, or standardization purposes.
Spread the word¶
BigFunctions is fully open-source. Help make it a success by spreading the word!