How can I remove a specific number from a string?

remove specific character from string excel
excel remove specific text from cell
remove unwanted characters in excel
how to remove special characters in excel
remove numbers from string javascript
remove numbers from string python
how to remove text before or after a specific character in excel?
remove text from excel cell leave numbers

here is the code:

aList = ['0.01', 'xyz', 'J0.01', 'abc', 'xyz'];
aList.remove('0.01');
print("List : ", aList)

here is the output: List :

['xyz', 'J0.01', 'abc', 'xyz']

How can I remove the 0.01 attached to 'J0.01'? I would like to keep the J. Thanks for your time! =)

Seems like you want

aList = ['0.01', 'xyz', 'J0.01', 'abc', 'xyz'];
>>> [z.replace('0.01', '') for z in aList]

['', 'xyz', 'J', 'abc', 'xyz']

If you want to remove also empty strings/whitespaces,

>>> [z.replace('0.01', '') for z in aList if z.replace('0.01', '').strip()]
['xyz', 'J', 'abc', 'xyz']

Online Text Filter Tools | Delete Only Numbers From Text Lines, Remove Certain | Specific (word ,letter ,number ,special characters..) . STEM | SEO | URLs | Text | Lists | Lines | Strings | Excel | NotePad ,Helpful Online Tools And  1. Select the cells you want to remove the specific characters, and then click Kutools > Text > Remove Characters. See screenshot: 2. Then in the Remove Characters dialog, check Custom option only, then type the characters you want to remove from strings, (it is case sensitive), you can see the result in the Preview pane. See screenshot: 3. Click Ok. Then all characters “S” are removed from each string of the selection.

Using re module:

import re

aList = ['0.01', 'xyz', 'J0.01', 'abc', 'xyz'];    
print([i for i in (re.sub(r'\d+\.?\d*$', '', i) for i in aList) if i])

Prints:

['xyz', 'J', 'abc', 'xyz']

EDIT:

The regexp substitution re.sub(r'\d+\.?\d*$', '', i) will substitute every digit followed by dot (optional) and followed by any number of digits for empty string. The $ signifies that the digit should be at the end of the string.

So. e.g. the following matches are valid: "0.01", "0.", "0". Explanation on external site here.

Excel formula: Remove unwanted characters, To remove specific unwanted characters in Excel, you can use a formula to find a character with code number 202, and replace it with an empty string ("")  The number 2 means the number of characters you want to remove from the beginning of the text string. 2. Then, select the cell C4 and drag the fill handle down to the cells where you want to apply this formula, and all the first 2 characters have been removed from the text strings,

Something like that can works:

l = ['0.01', 'xyz', 'J0.01', 'abc', 'xyz']
string = '0.01'
result = []
for x in l :
    if string in x:
        substring = x.replace(string,'')
        if substring != "":
            result.append(substring)
    else:
        result.append(x)

print(result)

try it, regards.

How To Remove First, Last X Characters Or Certain Position , doc remove first x characters 11 A4 is the cell value that you want to remove characters;; The number 3 is one more text strings, see screenshot:. Any num_digits_to_remove digits are removed from large as though removing characters from its string representation. The number that is returned has the lowest possible value from removing digits as in step 1.

Removing the first X number of characters from a string in Excel and , Occasionally you need to convert a specific string to remove some x number of characters at the beginning of the string. There is a very nifty function you can use​  The TRIM function allows you to trim leading and/or trailing characters from a string. The following shows the syntax of the TRIM function. First, specify the trim_character, which is the character that the TRIM function will remove. If you do not specify trim_character the TRIM function will remove the blank spaces from the source string.

Remove unwanted characters in Excel, To split numbers and text from a string use, I have written a different article. Here is your solution. https://www.exceltip.com/excel-text-formulas/split-numbers-and-​  Excel has a great built in function called SUBSTITUTE which allows you to find one bit of text within another text string and substitute it for another bit of text. Copy and paste this table into cell A1 in Excel. Ge%t rid% of thes%e perce%nt sig%ns. =SUBSTITUTE (A2,"%","") In the above example we can use the SUBSTITUTE function to clean the

Remove Characters From Right, So we give it the string first. Now we need to calculate the number of characters to be extracted. To do so we use LEN(string) function that returns the total number  To remove non-numeric characters from a text string, you can try this experimental formula based on the TEXTJOIN function, new in Excel 2016. In the example shown, the formula in C5 is: { = TEXTJOIN ( "" , TRUE , IFERROR ( MID ( B5 , ROW

Comments
  • sounds like a job for regex
  • You're using the list method remove. You want a string method instead
  • Thanks for the advice good sir! It worked like a charm.
  • You're amazing! Thanks a lot! =)
  • I assumed, incorrectly apparently, that he was looking for a generic solution to removing any number from any string.
  • @SuperStew Oh I see. It was kind of hard to understand I agree :) Jake Glad I could help
  • @SuperStew... I am trying to remove 0.01 attached to every name in a list. I should have been more clear. My apologies for any misunderstandings.
  • Thank you so much for your help! This code worked great! =)
  • Can you please add some explanation to the complicated expression in your print command in the interest of those who are new to re which includes me
  • Great, appreciated!
  • … I have a list of names with 0.01 attached to each of them. For example: Obama, Barak0.01; Trump, Don0.01; etc. When I tried using the code you suggested it only printed the last name in the list (i.e. Trump, Don). Any idea how I could use this code to remove the 0.01 from everyone in the list? This code worked as you stated. I am just new and could use some pointers. Thanks for you time! =)