Find and Replace based on non-numeric entry



  • I need some help, if possible, finding and replacing based on non-numeric entry.

    Sample:
    Find the below
    Account Number: Yukon Lease 2011
    Replace it with
    Description: Yukon Lease 2011

    So if the Account Number: is all numeric, it leaves it alone, but if it contains Alphanumeric the change Account Number: to Description:



  • @Jeff-Brewer said in Find and Replace based on non-numeric entry:

    So if the Account Number: is all numeric, it leaves it alone, but if it contains Alphanumeric the change Account Number: to Description:

    Usually it’s best to give examples that both should and shouldn’t match, so that we understand your restrictions – your example data only showed a matching, so if you hadn’t given that last sentence, we would have had no clue what you really wanted. As it is, I think I can guess what you intend. But showing better data that has both matching and non-matching sections (aka, shows both text to keep and text to change), along with before and after, properly formatted, will go a long way toward improving responses. See my recommendations below.

    • FIND = Account Number:(?=\h*[\w]*[\u\l]+)
    • REPLACE = Description:
    • Mode = regular expression

    Changes

    Account Number: Yukon Lease 2011
    Account Number: 20200917
    

    to

    Description: Yukon Lease 2011
    Account Number: 20200917
    

    If that isn’t the correct answer, you need to improve your specs, and make sure you follow the advice below.

    ----

    Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as plain text using the </> toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get… Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.



  • Thank you, that is what I was looking for. I have noted the request for better examples and will strive to do better next time.



  • Hi, @jeff-brewer, @peterjones and All,

    Just a shorter variant S/R :

    SEARCH Account Number(?=:\h*.*[\l\u])

    REPLACE Description

    Cheers,

    guy038


Log in to reply