Excel : script to identify text in one column (based on regex) and paste it in the next column once found










-1















I have an excel file with more than 10,000 columns of text like this(example):



Identified a potential Security Vulnerability CVE-2018-1231


Is there anyway i can identify the columns having CVE and write the whole CVE-2018-1231 in the next column by writing a regex or formula?










share|improve this question



















  • 4





    Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

    – SJR
    Nov 13 '18 at 12:21






  • 1





    Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

    – Hammad Qureshi
    Nov 13 '18 at 12:54











  • Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

    – SJR
    Nov 13 '18 at 12:58















-1















I have an excel file with more than 10,000 columns of text like this(example):



Identified a potential Security Vulnerability CVE-2018-1231


Is there anyway i can identify the columns having CVE and write the whole CVE-2018-1231 in the next column by writing a regex or formula?










share|improve this question



















  • 4





    Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

    – SJR
    Nov 13 '18 at 12:21






  • 1





    Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

    – Hammad Qureshi
    Nov 13 '18 at 12:54











  • Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

    – SJR
    Nov 13 '18 at 12:58













-1












-1








-1








I have an excel file with more than 10,000 columns of text like this(example):



Identified a potential Security Vulnerability CVE-2018-1231


Is there anyway i can identify the columns having CVE and write the whole CVE-2018-1231 in the next column by writing a regex or formula?










share|improve this question
















I have an excel file with more than 10,000 columns of text like this(example):



Identified a potential Security Vulnerability CVE-2018-1231


Is there anyway i can identify the columns having CVE and write the whole CVE-2018-1231 in the next column by writing a regex or formula?







excel vba excel-vba excel-formula excel-2010






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 12:56









Pᴇʜ

21k42650




21k42650










asked Nov 13 '18 at 12:16









Hammad QureshiHammad Qureshi

1




1







  • 4





    Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

    – SJR
    Nov 13 '18 at 12:21






  • 1





    Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

    – Hammad Qureshi
    Nov 13 '18 at 12:54











  • Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

    – SJR
    Nov 13 '18 at 12:58












  • 4





    Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

    – SJR
    Nov 13 '18 at 12:21






  • 1





    Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

    – Hammad Qureshi
    Nov 13 '18 at 12:54











  • Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

    – SJR
    Nov 13 '18 at 12:58







4




4





Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

– SJR
Nov 13 '18 at 12:21





Yes there are several ways of doing this. Why don't you go and do some research, try something and then post back when you have a specific problem?

– SJR
Nov 13 '18 at 12:21




1




1





Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

– Hammad Qureshi
Nov 13 '18 at 12:54





Hi @SJR, thanks for your response. I did some research and found that it can be done using ISNUMBER and SEARCH(example): =IF(ISNUMBER(SEARCH("apple",A2)),"Apple", What i am not sure about is how do i use this in numbers after "CVE-XXXX-XXXX"?

– Hammad Qureshi
Nov 13 '18 at 12:54













Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

– SJR
Nov 13 '18 at 12:58





Yes I don't think that will work for your situation although you can use wildcards in the SEARCH formula (but doesn't distinguish numbers from anything else). I think either the answer below or Regexp is probably the way to go here.

– SJR
Nov 13 '18 at 12:58












2 Answers
2






active

oldest

votes


















1














for cell A1 containing your example:



=if(isnumber(search("CVE";A1));right(A1;13);"")


with , as delimiter



=if(isnumber(search("CVE",A1)),right(A1,13),"")





share|improve this answer

























  • Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

    – Hammad Qureshi
    Nov 13 '18 at 12:34






  • 1





    possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

    – Lambik
    Nov 13 '18 at 12:41






  • 2





    The formulas are missing a closing parentheses (and therefore cannot work).

    – Pᴇʜ
    Nov 13 '18 at 13:02












  • corrected the missing parentheses, thanks for the remark

    – Lambik
    Nov 13 '18 at 14:55


















1














Use this formula in column B (assuming column A contains the data)



=IFERROR(MID(A1,SEARCH("CVE",A1),13),"")


This will even work if the CVE is not necessarily in the end. It will work for both examples below:



Column A | Column B
Identified a potential Security Vulnerability CVE-2018-1231 | CVE-2018-1231
Identified a potential Security Vulnerability CVE-2018-1232 aeuia e | CVE-2018-1232



If your CVE number is not constantly 13 characters you must use:



=IFERROR(MID(A1,SEARCH("CVE",A1),IFERROR(SEARCH(")",A1,SEARCH("CVE",A1)+1),IFERROR(SEARCH(" ",A1,SEARCH("CVE",A1)+1),LEN(A1)))-SEARCH("CVE",A1)),"")


This formula will cut out the CVE until a closing parentheses or a space comes or until the end of the text.






share|improve this answer

























  • Hi, many thanks for your answer. You almost made it work. :)

    – Hammad Qureshi
    Nov 13 '18 at 14:05











  • If it solved your issue please mark it as solution: Accepting Answers: How does it work?

    – Pᴇʜ
    Nov 13 '18 at 14:06











  • Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

    – Hammad Qureshi
    Nov 13 '18 at 14:14











  • As you will see, the last ")" in B1 is useless.

    – Hammad Qureshi
    Nov 13 '18 at 14:15











  • @HammadQureshi see my edit.

    – Pᴇʜ
    Nov 13 '18 at 14:23










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280829%2fexcel-script-to-identify-text-in-one-column-based-on-regex-and-paste-it-in-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














for cell A1 containing your example:



=if(isnumber(search("CVE";A1));right(A1;13);"")


with , as delimiter



=if(isnumber(search("CVE",A1)),right(A1,13),"")





share|improve this answer

























  • Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

    – Hammad Qureshi
    Nov 13 '18 at 12:34






  • 1





    possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

    – Lambik
    Nov 13 '18 at 12:41






  • 2





    The formulas are missing a closing parentheses (and therefore cannot work).

    – Pᴇʜ
    Nov 13 '18 at 13:02












  • corrected the missing parentheses, thanks for the remark

    – Lambik
    Nov 13 '18 at 14:55















1














for cell A1 containing your example:



=if(isnumber(search("CVE";A1));right(A1;13);"")


with , as delimiter



=if(isnumber(search("CVE",A1)),right(A1,13),"")





share|improve this answer

























  • Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

    – Hammad Qureshi
    Nov 13 '18 at 12:34






  • 1





    possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

    – Lambik
    Nov 13 '18 at 12:41






  • 2





    The formulas are missing a closing parentheses (and therefore cannot work).

    – Pᴇʜ
    Nov 13 '18 at 13:02












  • corrected the missing parentheses, thanks for the remark

    – Lambik
    Nov 13 '18 at 14:55













1












1








1







for cell A1 containing your example:



=if(isnumber(search("CVE";A1));right(A1;13);"")


with , as delimiter



=if(isnumber(search("CVE",A1)),right(A1,13),"")





share|improve this answer















for cell A1 containing your example:



=if(isnumber(search("CVE";A1));right(A1;13);"")


with , as delimiter



=if(isnumber(search("CVE",A1)),right(A1,13),"")






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 14:55

























answered Nov 13 '18 at 12:24









LambikLambik

468410




468410












  • Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

    – Hammad Qureshi
    Nov 13 '18 at 12:34






  • 1





    possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

    – Lambik
    Nov 13 '18 at 12:41






  • 2





    The formulas are missing a closing parentheses (and therefore cannot work).

    – Pᴇʜ
    Nov 13 '18 at 13:02












  • corrected the missing parentheses, thanks for the remark

    – Lambik
    Nov 13 '18 at 14:55

















  • Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

    – Hammad Qureshi
    Nov 13 '18 at 12:34






  • 1





    possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

    – Lambik
    Nov 13 '18 at 12:41






  • 2





    The formulas are missing a closing parentheses (and therefore cannot work).

    – Pᴇʜ
    Nov 13 '18 at 13:02












  • corrected the missing parentheses, thanks for the remark

    – Lambik
    Nov 13 '18 at 14:55
















Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

– Hammad Qureshi
Nov 13 '18 at 12:34





Hi, Many thanks for your response. I tried using this but didn't work. please have a look here.

– Hammad Qureshi
Nov 13 '18 at 12:34




1




1





possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

– Lambik
Nov 13 '18 at 12:41





possibly due to the fact that you are using , as delimiter instead of ; like I do. Change all ; to , and try again

– Lambik
Nov 13 '18 at 12:41




2




2





The formulas are missing a closing parentheses (and therefore cannot work).

– Pᴇʜ
Nov 13 '18 at 13:02






The formulas are missing a closing parentheses (and therefore cannot work).

– Pᴇʜ
Nov 13 '18 at 13:02














corrected the missing parentheses, thanks for the remark

– Lambik
Nov 13 '18 at 14:55





corrected the missing parentheses, thanks for the remark

– Lambik
Nov 13 '18 at 14:55













1














Use this formula in column B (assuming column A contains the data)



=IFERROR(MID(A1,SEARCH("CVE",A1),13),"")


This will even work if the CVE is not necessarily in the end. It will work for both examples below:



Column A | Column B
Identified a potential Security Vulnerability CVE-2018-1231 | CVE-2018-1231
Identified a potential Security Vulnerability CVE-2018-1232 aeuia e | CVE-2018-1232



If your CVE number is not constantly 13 characters you must use:



=IFERROR(MID(A1,SEARCH("CVE",A1),IFERROR(SEARCH(")",A1,SEARCH("CVE",A1)+1),IFERROR(SEARCH(" ",A1,SEARCH("CVE",A1)+1),LEN(A1)))-SEARCH("CVE",A1)),"")


This formula will cut out the CVE until a closing parentheses or a space comes or until the end of the text.






share|improve this answer

























  • Hi, many thanks for your answer. You almost made it work. :)

    – Hammad Qureshi
    Nov 13 '18 at 14:05











  • If it solved your issue please mark it as solution: Accepting Answers: How does it work?

    – Pᴇʜ
    Nov 13 '18 at 14:06











  • Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

    – Hammad Qureshi
    Nov 13 '18 at 14:14











  • As you will see, the last ")" in B1 is useless.

    – Hammad Qureshi
    Nov 13 '18 at 14:15











  • @HammadQureshi see my edit.

    – Pᴇʜ
    Nov 13 '18 at 14:23















1














Use this formula in column B (assuming column A contains the data)



=IFERROR(MID(A1,SEARCH("CVE",A1),13),"")


This will even work if the CVE is not necessarily in the end. It will work for both examples below:



Column A | Column B
Identified a potential Security Vulnerability CVE-2018-1231 | CVE-2018-1231
Identified a potential Security Vulnerability CVE-2018-1232 aeuia e | CVE-2018-1232



If your CVE number is not constantly 13 characters you must use:



=IFERROR(MID(A1,SEARCH("CVE",A1),IFERROR(SEARCH(")",A1,SEARCH("CVE",A1)+1),IFERROR(SEARCH(" ",A1,SEARCH("CVE",A1)+1),LEN(A1)))-SEARCH("CVE",A1)),"")


This formula will cut out the CVE until a closing parentheses or a space comes or until the end of the text.






share|improve this answer

























  • Hi, many thanks for your answer. You almost made it work. :)

    – Hammad Qureshi
    Nov 13 '18 at 14:05











  • If it solved your issue please mark it as solution: Accepting Answers: How does it work?

    – Pᴇʜ
    Nov 13 '18 at 14:06











  • Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

    – Hammad Qureshi
    Nov 13 '18 at 14:14











  • As you will see, the last ")" in B1 is useless.

    – Hammad Qureshi
    Nov 13 '18 at 14:15











  • @HammadQureshi see my edit.

    – Pᴇʜ
    Nov 13 '18 at 14:23













1












1








1







Use this formula in column B (assuming column A contains the data)



=IFERROR(MID(A1,SEARCH("CVE",A1),13),"")


This will even work if the CVE is not necessarily in the end. It will work for both examples below:



Column A | Column B
Identified a potential Security Vulnerability CVE-2018-1231 | CVE-2018-1231
Identified a potential Security Vulnerability CVE-2018-1232 aeuia e | CVE-2018-1232



If your CVE number is not constantly 13 characters you must use:



=IFERROR(MID(A1,SEARCH("CVE",A1),IFERROR(SEARCH(")",A1,SEARCH("CVE",A1)+1),IFERROR(SEARCH(" ",A1,SEARCH("CVE",A1)+1),LEN(A1)))-SEARCH("CVE",A1)),"")


This formula will cut out the CVE until a closing parentheses or a space comes or until the end of the text.






share|improve this answer















Use this formula in column B (assuming column A contains the data)



=IFERROR(MID(A1,SEARCH("CVE",A1),13),"")


This will even work if the CVE is not necessarily in the end. It will work for both examples below:



Column A | Column B
Identified a potential Security Vulnerability CVE-2018-1231 | CVE-2018-1231
Identified a potential Security Vulnerability CVE-2018-1232 aeuia e | CVE-2018-1232



If your CVE number is not constantly 13 characters you must use:



=IFERROR(MID(A1,SEARCH("CVE",A1),IFERROR(SEARCH(")",A1,SEARCH("CVE",A1)+1),IFERROR(SEARCH(" ",A1,SEARCH("CVE",A1)+1),LEN(A1)))-SEARCH("CVE",A1)),"")


This formula will cut out the CVE until a closing parentheses or a space comes or until the end of the text.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 14:55

























answered Nov 13 '18 at 13:04









PᴇʜPᴇʜ

21k42650




21k42650












  • Hi, many thanks for your answer. You almost made it work. :)

    – Hammad Qureshi
    Nov 13 '18 at 14:05











  • If it solved your issue please mark it as solution: Accepting Answers: How does it work?

    – Pᴇʜ
    Nov 13 '18 at 14:06











  • Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

    – Hammad Qureshi
    Nov 13 '18 at 14:14











  • As you will see, the last ")" in B1 is useless.

    – Hammad Qureshi
    Nov 13 '18 at 14:15











  • @HammadQureshi see my edit.

    – Pᴇʜ
    Nov 13 '18 at 14:23

















  • Hi, many thanks for your answer. You almost made it work. :)

    – Hammad Qureshi
    Nov 13 '18 at 14:05











  • If it solved your issue please mark it as solution: Accepting Answers: How does it work?

    – Pᴇʜ
    Nov 13 '18 at 14:06











  • Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

    – Hammad Qureshi
    Nov 13 '18 at 14:14











  • As you will see, the last ")" in B1 is useless.

    – Hammad Qureshi
    Nov 13 '18 at 14:15











  • @HammadQureshi see my edit.

    – Pᴇʜ
    Nov 13 '18 at 14:23
















Hi, many thanks for your answer. You almost made it work. :)

– Hammad Qureshi
Nov 13 '18 at 14:05





Hi, many thanks for your answer. You almost made it work. :)

– Hammad Qureshi
Nov 13 '18 at 14:05













If it solved your issue please mark it as solution: Accepting Answers: How does it work?

– Pᴇʜ
Nov 13 '18 at 14:06





If it solved your issue please mark it as solution: Accepting Answers: How does it work?

– Pᴇʜ
Nov 13 '18 at 14:06













Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

– Hammad Qureshi
Nov 13 '18 at 14:14





Just one last question. We are using 13 digits string in output, and considering "1231" (the last part) will only be 4 digits, when i have 5 digit long string in the last part and change the "13" digit limit to 14, it takes one extra character in the end f our digit as well. HERES an example. Can you suggested something to remediate this?

– Hammad Qureshi
Nov 13 '18 at 14:14













As you will see, the last ")" in B1 is useless.

– Hammad Qureshi
Nov 13 '18 at 14:15





As you will see, the last ")" in B1 is useless.

– Hammad Qureshi
Nov 13 '18 at 14:15













@HammadQureshi see my edit.

– Pᴇʜ
Nov 13 '18 at 14:23





@HammadQureshi see my edit.

– Pᴇʜ
Nov 13 '18 at 14:23

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280829%2fexcel-script-to-identify-text-in-one-column-based-on-regex-and-paste-it-in-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto