ShowAll Questionssorted byDate Posted ard_17

# How to find and replace string between two characters in formula?

I have a text field that could contain text like:
"Please consult the related form [15dr4] for details"

But I'm trying to create a separate formula field that will hide the "15dr4" or whatever text is between the two brackets, but display the rest of the text.l Is this possible?

I appreciate any help. Thanks! Shri Raj

Yes, it is possible to find and replace a string between two characters in a formula field. One way to accomplish this is to use the MID and FIND functions in combination with one another.

`=LEFT(A1,FIND("[",A1)-1) & RIGHT(A1,LEN(A1)-FIND("]",A1))`

This formula uses the LEFT function to return the portion of the string before the first [, and the RIGHT function to return the portion of the string after the last ]. The FIND function is used to locate the positions of the brackets. This formula can be used to replace the text between the two brackets with an empty string, effectively hiding it. Shivam Solanki
Here is the syntax in different programming languages:

In Python

def replace_between_chars(string, char1, char2, replace_with):
start = string.index(char1)
end = string.index(char2, start)
return string[:start + 1] + replace_with + string[end:]

In Java:

public static String replaceBetween(String str, String replace, char start, char end) {
int startIndex = str.indexOf(start) + 1;
int endIndex = str.indexOf(end, startIndex);
return str.substring(0, startIndex) + replace + str.substring(endIndex);
}

In JavaScript:

function replaceBetween(string, char1, char2, replaceWith) {
let start = string.indexOf(char1) + 1;
let end = string.indexOf(char2, start);
return string.substring(0, start) + replaceWith + string.substring(end);
}

In PHP:

function replace_between_chars(\$string, \$char1, \$char2, \$replace_with) {
\$start = strpos(\$string, \$char1) + 1;
\$end = strpos(\$string, \$char2, \$start);
return substr_replace(\$string, \$replace_with, \$start, \$end - \$start);
}

https://pickon.in/bolly4u-movies-bollywood-hollywood/
https://pickon.in/soap2day-to/
https://pickon.in/vegamovies/
https://pickon.in/katmoviehd/
https://pickon.in/that-90s-show-soap2day-review/ Arun Kumar 1141
Hi ard_17,

Yes, it's possible to create a formula field that will hide the text between the brackets and display the rest of the text. Here's an example formula that you could use:

LEFT(Text_Field__c, FIND("[", Text_Field__c) - 1) & RIGHT(Text_Field__c, LEN(Text_Field__c) - FIND("]", Text_Field__c))

Replace "Text_Field__c" with the API name of your text field.

This formula uses the LEFT and RIGHT functions to extract the text before and after the brackets. The FIND function is used to find the positions of the opening and closing brackets, and the LEN function is used to calculate the length of the string.

This formula assumes that the text field always contains the brackets with text in between. If there's a possibility that the brackets may not be present, you can modify the formula to include a check for that, for example:

IF(
FIND("[", Text_Field__c) > 0 && FIND("]", Text_Field__c) > 0,
LEFT(Text_Field__c, FIND("[", Text_Field__c) - 1) & RIGHT(Text_Field__c, LEN(Text_Field__c) - FIND("]", Text_Field__c)),
Text_Field__c
)
This formula checks if both brackets are present before extracting the text. If the brackets are not present, it simply returns the original text.

Thanks pomij marya
It's great to be here with everyone, I have a lot of knowledge from what you share cashewsinfo toby bishop
Yes, it is possible to create a formula field that hides the text between brackets and displays the rest of the text. You can achieve this using string manipulation functions in the programming language or platform you are working with.

Here's an example formula that you can adapt to your specific programming language or platform:

```python
text = "Please consult the related form [15dr4] for details"
start_index = text.find("[")  # Find the index of the opening bracket
end_index = text.find("]")  # Find the index of the closing bracket

if start_index != -1 and end_index != -1:  # If both brackets are present
hidden_text = text[start_index+1:end_index]  # Extract the text between brackets
visible_text = text[:start_index] + text[end_index+1:]  # Concatenate the text before and after the brackets
else:
hidden_text = ""  # If the brackets are not found, there is no hidden text
visible_text = text  # The entire text is visible

print("Hidden Text:", hidden_text)
print("Visible Text:", visible_text)
```

In this example, the `find()` function is used to locate the positions of the opening and closing brackets. If both brackets are found, the text between them is extracted and stored in the `hidden_text` variable. The visible text is obtained by concatenating the text before the opening bracket (`text[:start_index]`) with the text after the closing bracket (`text[end_index+1:]`).

You can adapt this logic to your specific programming language or platform to achieve the desired result in your application or system.
theapk (https://theapkasphalt.com) Christine G. Williams Williams
Hello,
There are many ways to find and replace strings between two characters. like this:
```import re

formula = "SUM(A1:A10)"
replacement = "B1:B10"

new_formula = re.sub(r'\(.*?\)', f'({replacement})', formula)
print(new_formula)  # Output: SUM(B1:B10)```

In this example, it is in a python language. it's simply to find in pythonhttps://www.myfedloan.us/
{"ft_lang_label":"__label__en","ft_lang_prob":0.7645615,"math_prob":0.80927134,"size":5118,"snap":"2023-40-2023-50","text_gpt3_token_len":1211,"char_repetition_ratio":0.15447791,"word_repetition_ratio":0.19842313,"special_character_ratio":0.2516608,"punctuation_ratio":0.14918919,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96159637,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-26T03:37:06Z\",\"WARC-Record-ID\":\"<urn:uuid:e54ea70c-0f3e-43bd-9092-af58340d91aa>\",\"Content-Length\":\"224399\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:108eb43f-ed47-47a3-88c7-2a13fce6780c>\",\"WARC-Concurrent-To\":\"<urn:uuid:943c60bd-56f5-45e7-b887-c29ac8103ef7>\",\"WARC-IP-Address\":\"23.222.79.104\",\"WARC-Target-URI\":\"https://dfc-org-production.my.site.com/forums/ForumsMain?id=9062I000000R5X6QAK\",\"WARC-Payload-Digest\":\"sha1:MJUUFWOBXCR4OSRM57ECKN3NG76WG554\",\"WARC-Block-Digest\":\"sha1:GYHYGUWXI7IZN7PUKEISUS3DFJCXTQIH\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510130.53_warc_CC-MAIN-20230926011608-20230926041608-00192.warc.gz\"}"}