How to cut first characters until a special character found?

how to remove text before or after a specific character in excel?
how to remove all characters after a specific character in java
excel remove specific text from cell
excel remove text after character
how to trim a string after a specific character in java
remove specific character from string excel
excel extract text before character
how to remove part of text in a cell in excel

I have 100 lines where each line consists of some sentences.Each line starts with some characters followed by -rrb-.

How can I format the text so that each line actually starts after the -rrb-.

Line Example:

Lorem ipsum -lrb- dolor -rrb- sit amet, consectetur adipiscing elit. Nam quis dolor a sapien efficitur fermentum egestas ut elit. Nulla porttitor diam id orci bibendum volutpat. Quisque imperdiet euismod neque in efficitur.

I want for this and every line:

sit amet, consectetur adipiscing elit. Nam quis dolor a sapien efficitur fermentum egestas ut elit. Nulla porttitor diam id orci bibendum volutpat. Quisque imperdiet euismod neque in efficitur.

So I want to start this and every 100 lines from the word after -rrb- ( "sit" for this example).

just index it out:

print(s[s.index('-rrb-')+6:])

Output:

sit amet, consectetur adipiscing elit. Nam quis dolor a sapien efficitur fermentum egestas ut elit. Nulla porttitor diam id orci bibendum volutpat. Quisque imperdiet euismod neque in efficitur.

How to remove all characters before a specific character in Java , You can use .substring() : String s = "the text=text"; String s1 = s.substring(s.​indexOf("=")+1); s1.trim();. then s1 contains everything after = in the  Step 1: To find the location of the special character. Step 2: Pick up the letters before the special character. Please change the special character in the formula if you need to extract text with another character. For example, please change "." to "–" in the formula if you need to extract text before the character "-".

Use split:

text = line.split('-rrb-', 1)[-1]

How to remove text before the first match of a specific character in , How to remove all characters before the first match of the comma or the FIND function to get the length of substring that after the first comma. text: It is the text string that contains character that you want to extract. num_chars: It specifies the number of characters from left you want to extract. The SEARCH function returns the number of the character at which a specific character or text string is first found, reading left to right (not case-sensitive)

@NavaW, you can try the below code to get the sentence after -rrb- for 1 line.

Finally you can loop over 100 lines and process each lines.

line = "Lorem ipsum -lrb- dolor -rrb- sit amet, consectetur adipiscing elit. Nam quis dolor a sapien efficitur fermentum egestas ut elit. Nulla porttitor diam id orci bibendum volutpat. Quisque imperdiet euismod neque in efficitur."
new_line = line.split("-rrb-")[1].strip()
print(new_line)

"""
sit amet, consectetur adipiscing elit. Nam quis dolor a sapien efficitur fermentum egestas ut elit. Nulla porttitor diam id orci bibendum volutpat. Quisque imperdiet euismod neque in efficitur.
"""

How to remove texts before or after a specific character from cells in , Easily remove all numeric, non-numeric or specified characters from cells in Excel. Kutools for Excel's Delete texts before or after specific character by Find and Replace in Excel Formula: Remove everything before the first comma. For removing all texts before or after a specific character with the Find and Replace function, please do as follows. 1. Select the cells you will remove texts before or after a specific character, press Ctrl + H keys to open the Find and Replace dialog.

Bash: How can i remove characters from a string until i hit a specific , Bash: How can i remove characters from a string until i hit a specific character or whatever the equivalent is for removing the first characters to  The first formula uses the FIND function to locate the underscore(_) in the text, then we subtract 1 to move back to the "character before the special character". FIND ("_", B5) - 1 In this example, FIND returns 7, so we end up with 6.

[Solved] trim a string before a special character in c#, You could grab a substring starting from the index of the special character: Hide Copy Code. string newstring = str.Substring(str.IndexOf(">")); I have a column A with data and I need extract text before character ("-") and send to column B and extract the text after character ("-") and send to column C. Example for that I need: This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread.

Excel formula: Split text string at specific character, The first formula uses the FIND function to locate the underscore(_) in the text, then we subtract 1 to move back to the "character before the special character". as "num_chars" - the number of characters to extract from B5, starting from the left​: To trim text to a certain number of words, you can use a formula based on the​  You can quickly extract the text before space from the list only by using formula. Select a blank cell, and type this formula =LEFT(A1,(FIND(" ",A1,1)-1)) (A1 is the first cell of the list you want to extract text) , and press Enter button. Tips: (1) If you want to extract text before or after comma, you can change " "to ",".

Comments
  • what did you try? where is the code you have problems with?
  • Can you paste 1 sample of i/p and expected o/p?
  • It looks like only this answer takes into account the multiple existence of '-rrb-' in a line.