Trouble with counting and highlightsHow to get line count cheaply in Python?Count the number occurrences of a character in a stringHow can I count the occurrences of a list item?Counting unique wordsHow would I index words on each linePrint the line number of a text file for each word from a list in python 3 without importing anythingAll lists get overwritten in PythonCount most common titular words in a paragraph of textCalculating Statistics From FileWord count from a txt file and output to file

Don't look at what I did there

In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?

Under GDPR, can I give permission once to allow everyone to store and process my data?

'spazieren' - walking in a silly and affected manner?

Terminology of atomic spectroscopy: Difference Among Term, States and Level

Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?

Where should I draw the line on follow up questions from previous employer

Is this homebrew "Faerie Fire Grenade" unbalanced?

GPL Licensed Woocommerce paid plugins

How to investigate an unknown 1.5GB file named "sudo" in my Linux home directory?

find the logic in first 2 statement to give the answer for the third statement

Is Borg adaptation only temporary?

“all of who” or “all of whom”?

How do I portray irrational anger in first person?

German equivalent to "going down the rabbit hole"

Why is there no Disney logo in MCU movies?

Strange behavior of std::initializer_list of std::strings

Which has less energy loss - AC step up/step down transformers or DC to DC step up/down converters?

My colleague treats me like he's my boss, yet we're on the same level

Which is the correct version of Mussorgsky's Pictures at an Exhibition?

Could a complex system of reaction wheels be used to propel a spacecraft?

What are ways to record who took the pictures if a camera is used by multiple people?

What was Captain Marvel supposed to do once she reached her destination?

In what language did Túrin converse with Mím?



Trouble with counting and highlights


How to get line count cheaply in Python?Count the number occurrences of a character in a stringHow can I count the occurrences of a list item?Counting unique wordsHow would I index words on each linePrint the line number of a text file for each word from a list in python 3 without importing anythingAll lists get overwritten in PythonCount most common titular words in a paragraph of textCalculating Statistics From FileWord count from a txt file and output to file






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am trying to create two functions. One uses two arguments, a filename, and a keyword. It needs to highlight the word and return the highlighted word or words with the line number.



The second function counts the number of times a specific word occurs in a file. Once again this one uses two arguments a filename and a keyword.



This one is called highlight. It needs to look at each line, find the keyword, then returns the line number with the keyword highlighted bracketed by '-->' on the left and '<--" on the right.



def highlight(filename, keyword):
inpt = open(filename, "r")
for line in inpt:
if re.match(keyword, line):
print ('-->',line,'<--')


This function uses a filename and keyword and counts the number of times a specific word occurs in a file, then returns the count.



def count_word(filename, keyword):
fname = (filename)
word= (keyword)
count = 0
with open(fname, 'r') as in_file:
for line in in_file:
words = line.split()
for i in words:
if(i==word):
count=count+1
print (count)


Am I going in completely the wrong direction? Am I close at all?



The text file reads:



I heart Rocket!
Rocket, Rocket, Rocket.
Don't say it.
Rocket, Rocket, Rocket!





Rocket!!!


Right now I am getting:



highlight:
printed:
--> Rocket, Rocket, Rocket.
<--
--> Rocket, Rocket, Rocket!
<--
--> Rocket!!!
<--

expected:
1: I heart -->Rocket<--!
2: -->Rocket<--, -->Rocket<--, -->Rocket<--.
4: -->Rocket<--, -->Rocket<--, -->Rocket<--!
10: -->Rocket<--!!!


count_word:

printed:
0
0
0
0
0
0
0
0
0
0
0
0
0

expected:
8









share|improve this question
































    1















    I am trying to create two functions. One uses two arguments, a filename, and a keyword. It needs to highlight the word and return the highlighted word or words with the line number.



    The second function counts the number of times a specific word occurs in a file. Once again this one uses two arguments a filename and a keyword.



    This one is called highlight. It needs to look at each line, find the keyword, then returns the line number with the keyword highlighted bracketed by '-->' on the left and '<--" on the right.



    def highlight(filename, keyword):
    inpt = open(filename, "r")
    for line in inpt:
    if re.match(keyword, line):
    print ('-->',line,'<--')


    This function uses a filename and keyword and counts the number of times a specific word occurs in a file, then returns the count.



    def count_word(filename, keyword):
    fname = (filename)
    word= (keyword)
    count = 0
    with open(fname, 'r') as in_file:
    for line in in_file:
    words = line.split()
    for i in words:
    if(i==word):
    count=count+1
    print (count)


    Am I going in completely the wrong direction? Am I close at all?



    The text file reads:



    I heart Rocket!
    Rocket, Rocket, Rocket.
    Don't say it.
    Rocket, Rocket, Rocket!





    Rocket!!!


    Right now I am getting:



    highlight:
    printed:
    --> Rocket, Rocket, Rocket.
    <--
    --> Rocket, Rocket, Rocket!
    <--
    --> Rocket!!!
    <--

    expected:
    1: I heart -->Rocket<--!
    2: -->Rocket<--, -->Rocket<--, -->Rocket<--.
    4: -->Rocket<--, -->Rocket<--, -->Rocket<--!
    10: -->Rocket<--!!!


    count_word:

    printed:
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0

    expected:
    8









    share|improve this question




























      1












      1








      1








      I am trying to create two functions. One uses two arguments, a filename, and a keyword. It needs to highlight the word and return the highlighted word or words with the line number.



      The second function counts the number of times a specific word occurs in a file. Once again this one uses two arguments a filename and a keyword.



      This one is called highlight. It needs to look at each line, find the keyword, then returns the line number with the keyword highlighted bracketed by '-->' on the left and '<--" on the right.



      def highlight(filename, keyword):
      inpt = open(filename, "r")
      for line in inpt:
      if re.match(keyword, line):
      print ('-->',line,'<--')


      This function uses a filename and keyword and counts the number of times a specific word occurs in a file, then returns the count.



      def count_word(filename, keyword):
      fname = (filename)
      word= (keyword)
      count = 0
      with open(fname, 'r') as in_file:
      for line in in_file:
      words = line.split()
      for i in words:
      if(i==word):
      count=count+1
      print (count)


      Am I going in completely the wrong direction? Am I close at all?



      The text file reads:



      I heart Rocket!
      Rocket, Rocket, Rocket.
      Don't say it.
      Rocket, Rocket, Rocket!





      Rocket!!!


      Right now I am getting:



      highlight:
      printed:
      --> Rocket, Rocket, Rocket.
      <--
      --> Rocket, Rocket, Rocket!
      <--
      --> Rocket!!!
      <--

      expected:
      1: I heart -->Rocket<--!
      2: -->Rocket<--, -->Rocket<--, -->Rocket<--.
      4: -->Rocket<--, -->Rocket<--, -->Rocket<--!
      10: -->Rocket<--!!!


      count_word:

      printed:
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0

      expected:
      8









      share|improve this question
















      I am trying to create two functions. One uses two arguments, a filename, and a keyword. It needs to highlight the word and return the highlighted word or words with the line number.



      The second function counts the number of times a specific word occurs in a file. Once again this one uses two arguments a filename and a keyword.



      This one is called highlight. It needs to look at each line, find the keyword, then returns the line number with the keyword highlighted bracketed by '-->' on the left and '<--" on the right.



      def highlight(filename, keyword):
      inpt = open(filename, "r")
      for line in inpt:
      if re.match(keyword, line):
      print ('-->',line,'<--')


      This function uses a filename and keyword and counts the number of times a specific word occurs in a file, then returns the count.



      def count_word(filename, keyword):
      fname = (filename)
      word= (keyword)
      count = 0
      with open(fname, 'r') as in_file:
      for line in in_file:
      words = line.split()
      for i in words:
      if(i==word):
      count=count+1
      print (count)


      Am I going in completely the wrong direction? Am I close at all?



      The text file reads:



      I heart Rocket!
      Rocket, Rocket, Rocket.
      Don't say it.
      Rocket, Rocket, Rocket!





      Rocket!!!


      Right now I am getting:



      highlight:
      printed:
      --> Rocket, Rocket, Rocket.
      <--
      --> Rocket, Rocket, Rocket!
      <--
      --> Rocket!!!
      <--

      expected:
      1: I heart -->Rocket<--!
      2: -->Rocket<--, -->Rocket<--, -->Rocket<--.
      4: -->Rocket<--, -->Rocket<--, -->Rocket<--!
      10: -->Rocket<--!!!


      count_word:

      printed:
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0
      0

      expected:
      8






      python python-3.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 22:14









      Patrick Artner

      29.7k6 gold badges26 silver badges45 bronze badges




      29.7k6 gold badges26 silver badges45 bronze badges










      asked Mar 27 at 21:48









      J.a. MartinJ.a. Martin

      184 bronze badges




      184 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1















          If you iterate lines from a file, each line ends with a newline 'n'.



          If you prepend '-->' and append '<--', the '<--' is added after the newline character. You could change your code, remove the n and add <-- .. but it can be done far easier:



          • replace text with str.replace("replace what","replace with what")


          • enumerate (iterable, start) your lines

          • use f-string formatting

          • count using str.count()

          Create file:



          with open("k.txt","w") as f:
          f.write("""I heart Rocket!
          Rocket, Rocket, Rocket.
          Don't say it.
          Rocket, Rocket, Rocket!





          Rocket!!!""")


          Process file:



          with open("k.txt") as f:

          # read all text
          text = f.read()

          # replace Rocket with -->Rocket<-- and store as text2
          text2 = text.replace("Rocket","-->Rocket<--")

          # split at n, enumerate result starting at 1, remove any line
          # that does not contain Rocket, join with n
          text3 = text2.split("n")
          text4 = [f"row:2d x" for row,x in enumerate(text3,1) if "Rocket" in x]
          text5 = "n".join(text4)

          # Count rockets and print replaced text
          print(text.count("Rocket"))
          print(text3)
          print(text4)
          print(text5)


          Output:



          # the rocket count
          8

          # text3: all lines
          ['I heart -->Rocket<--!', '-->Rocket<--, -->Rocket<--, -->Rocket<--.', "Don't say it.",
          '-->Rocket<--, -->Rocket<--, -->Rocket<--!', '', '', '', '', '', '-->Rocket<--!!!']

          # text4: with enumeration of line number
          [' 1 I heart -->Rocket<--!', ' 2 -->Rocket<--, -->Rocket<--, -->Rocket<--.',
          ' 4 -->Rocket<--, -->Rocket<--, -->Rocket<--!', '10 -->Rocket<--!!!']

          # joined together again
          1 I heart -->Rocket<--!
          2 -->Rocket<--, -->Rocket<--, -->Rocket<--.
          4 -->Rocket<--, -->Rocket<--, -->Rocket<--!
          10 -->Rocket<--!!!



          If you want to confuse yourself you can do it as 4-liner:



          with open("k.txt") as f:
          text = "n".join(
          [f"row:2d x" for row,x
          in enumerate( f.read().replace("Rocket","-->Rocket<--").split("n"),1)
          if "Rocket" in x])
          print(text.count("Rocket"))
          print(text)





          share|improve this answer



























          • That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

            – J.a. Martin
            Mar 28 at 23:15












          • @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

            – Patrick Artner
            Mar 29 at 7:56











          • Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

            – J.a. Martin
            Mar 29 at 21:18










          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%2f55386983%2ftrouble-with-counting-and-highlights%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1















          If you iterate lines from a file, each line ends with a newline 'n'.



          If you prepend '-->' and append '<--', the '<--' is added after the newline character. You could change your code, remove the n and add <-- .. but it can be done far easier:



          • replace text with str.replace("replace what","replace with what")


          • enumerate (iterable, start) your lines

          • use f-string formatting

          • count using str.count()

          Create file:



          with open("k.txt","w") as f:
          f.write("""I heart Rocket!
          Rocket, Rocket, Rocket.
          Don't say it.
          Rocket, Rocket, Rocket!





          Rocket!!!""")


          Process file:



          with open("k.txt") as f:

          # read all text
          text = f.read()

          # replace Rocket with -->Rocket<-- and store as text2
          text2 = text.replace("Rocket","-->Rocket<--")

          # split at n, enumerate result starting at 1, remove any line
          # that does not contain Rocket, join with n
          text3 = text2.split("n")
          text4 = [f"row:2d x" for row,x in enumerate(text3,1) if "Rocket" in x]
          text5 = "n".join(text4)

          # Count rockets and print replaced text
          print(text.count("Rocket"))
          print(text3)
          print(text4)
          print(text5)


          Output:



          # the rocket count
          8

          # text3: all lines
          ['I heart -->Rocket<--!', '-->Rocket<--, -->Rocket<--, -->Rocket<--.', "Don't say it.",
          '-->Rocket<--, -->Rocket<--, -->Rocket<--!', '', '', '', '', '', '-->Rocket<--!!!']

          # text4: with enumeration of line number
          [' 1 I heart -->Rocket<--!', ' 2 -->Rocket<--, -->Rocket<--, -->Rocket<--.',
          ' 4 -->Rocket<--, -->Rocket<--, -->Rocket<--!', '10 -->Rocket<--!!!']

          # joined together again
          1 I heart -->Rocket<--!
          2 -->Rocket<--, -->Rocket<--, -->Rocket<--.
          4 -->Rocket<--, -->Rocket<--, -->Rocket<--!
          10 -->Rocket<--!!!



          If you want to confuse yourself you can do it as 4-liner:



          with open("k.txt") as f:
          text = "n".join(
          [f"row:2d x" for row,x
          in enumerate( f.read().replace("Rocket","-->Rocket<--").split("n"),1)
          if "Rocket" in x])
          print(text.count("Rocket"))
          print(text)





          share|improve this answer



























          • That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

            – J.a. Martin
            Mar 28 at 23:15












          • @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

            – Patrick Artner
            Mar 29 at 7:56











          • Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

            – J.a. Martin
            Mar 29 at 21:18















          1















          If you iterate lines from a file, each line ends with a newline 'n'.



          If you prepend '-->' and append '<--', the '<--' is added after the newline character. You could change your code, remove the n and add <-- .. but it can be done far easier:



          • replace text with str.replace("replace what","replace with what")


          • enumerate (iterable, start) your lines

          • use f-string formatting

          • count using str.count()

          Create file:



          with open("k.txt","w") as f:
          f.write("""I heart Rocket!
          Rocket, Rocket, Rocket.
          Don't say it.
          Rocket, Rocket, Rocket!





          Rocket!!!""")


          Process file:



          with open("k.txt") as f:

          # read all text
          text = f.read()

          # replace Rocket with -->Rocket<-- and store as text2
          text2 = text.replace("Rocket","-->Rocket<--")

          # split at n, enumerate result starting at 1, remove any line
          # that does not contain Rocket, join with n
          text3 = text2.split("n")
          text4 = [f"row:2d x" for row,x in enumerate(text3,1) if "Rocket" in x]
          text5 = "n".join(text4)

          # Count rockets and print replaced text
          print(text.count("Rocket"))
          print(text3)
          print(text4)
          print(text5)


          Output:



          # the rocket count
          8

          # text3: all lines
          ['I heart -->Rocket<--!', '-->Rocket<--, -->Rocket<--, -->Rocket<--.', "Don't say it.",
          '-->Rocket<--, -->Rocket<--, -->Rocket<--!', '', '', '', '', '', '-->Rocket<--!!!']

          # text4: with enumeration of line number
          [' 1 I heart -->Rocket<--!', ' 2 -->Rocket<--, -->Rocket<--, -->Rocket<--.',
          ' 4 -->Rocket<--, -->Rocket<--, -->Rocket<--!', '10 -->Rocket<--!!!']

          # joined together again
          1 I heart -->Rocket<--!
          2 -->Rocket<--, -->Rocket<--, -->Rocket<--.
          4 -->Rocket<--, -->Rocket<--, -->Rocket<--!
          10 -->Rocket<--!!!



          If you want to confuse yourself you can do it as 4-liner:



          with open("k.txt") as f:
          text = "n".join(
          [f"row:2d x" for row,x
          in enumerate( f.read().replace("Rocket","-->Rocket<--").split("n"),1)
          if "Rocket" in x])
          print(text.count("Rocket"))
          print(text)





          share|improve this answer



























          • That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

            – J.a. Martin
            Mar 28 at 23:15












          • @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

            – Patrick Artner
            Mar 29 at 7:56











          • Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

            – J.a. Martin
            Mar 29 at 21:18













          1














          1










          1









          If you iterate lines from a file, each line ends with a newline 'n'.



          If you prepend '-->' and append '<--', the '<--' is added after the newline character. You could change your code, remove the n and add <-- .. but it can be done far easier:



          • replace text with str.replace("replace what","replace with what")


          • enumerate (iterable, start) your lines

          • use f-string formatting

          • count using str.count()

          Create file:



          with open("k.txt","w") as f:
          f.write("""I heart Rocket!
          Rocket, Rocket, Rocket.
          Don't say it.
          Rocket, Rocket, Rocket!





          Rocket!!!""")


          Process file:



          with open("k.txt") as f:

          # read all text
          text = f.read()

          # replace Rocket with -->Rocket<-- and store as text2
          text2 = text.replace("Rocket","-->Rocket<--")

          # split at n, enumerate result starting at 1, remove any line
          # that does not contain Rocket, join with n
          text3 = text2.split("n")
          text4 = [f"row:2d x" for row,x in enumerate(text3,1) if "Rocket" in x]
          text5 = "n".join(text4)

          # Count rockets and print replaced text
          print(text.count("Rocket"))
          print(text3)
          print(text4)
          print(text5)


          Output:



          # the rocket count
          8

          # text3: all lines
          ['I heart -->Rocket<--!', '-->Rocket<--, -->Rocket<--, -->Rocket<--.', "Don't say it.",
          '-->Rocket<--, -->Rocket<--, -->Rocket<--!', '', '', '', '', '', '-->Rocket<--!!!']

          # text4: with enumeration of line number
          [' 1 I heart -->Rocket<--!', ' 2 -->Rocket<--, -->Rocket<--, -->Rocket<--.',
          ' 4 -->Rocket<--, -->Rocket<--, -->Rocket<--!', '10 -->Rocket<--!!!']

          # joined together again
          1 I heart -->Rocket<--!
          2 -->Rocket<--, -->Rocket<--, -->Rocket<--.
          4 -->Rocket<--, -->Rocket<--, -->Rocket<--!
          10 -->Rocket<--!!!



          If you want to confuse yourself you can do it as 4-liner:



          with open("k.txt") as f:
          text = "n".join(
          [f"row:2d x" for row,x
          in enumerate( f.read().replace("Rocket","-->Rocket<--").split("n"),1)
          if "Rocket" in x])
          print(text.count("Rocket"))
          print(text)





          share|improve this answer















          If you iterate lines from a file, each line ends with a newline 'n'.



          If you prepend '-->' and append '<--', the '<--' is added after the newline character. You could change your code, remove the n and add <-- .. but it can be done far easier:



          • replace text with str.replace("replace what","replace with what")


          • enumerate (iterable, start) your lines

          • use f-string formatting

          • count using str.count()

          Create file:



          with open("k.txt","w") as f:
          f.write("""I heart Rocket!
          Rocket, Rocket, Rocket.
          Don't say it.
          Rocket, Rocket, Rocket!





          Rocket!!!""")


          Process file:



          with open("k.txt") as f:

          # read all text
          text = f.read()

          # replace Rocket with -->Rocket<-- and store as text2
          text2 = text.replace("Rocket","-->Rocket<--")

          # split at n, enumerate result starting at 1, remove any line
          # that does not contain Rocket, join with n
          text3 = text2.split("n")
          text4 = [f"row:2d x" for row,x in enumerate(text3,1) if "Rocket" in x]
          text5 = "n".join(text4)

          # Count rockets and print replaced text
          print(text.count("Rocket"))
          print(text3)
          print(text4)
          print(text5)


          Output:



          # the rocket count
          8

          # text3: all lines
          ['I heart -->Rocket<--!', '-->Rocket<--, -->Rocket<--, -->Rocket<--.', "Don't say it.",
          '-->Rocket<--, -->Rocket<--, -->Rocket<--!', '', '', '', '', '', '-->Rocket<--!!!']

          # text4: with enumeration of line number
          [' 1 I heart -->Rocket<--!', ' 2 -->Rocket<--, -->Rocket<--, -->Rocket<--.',
          ' 4 -->Rocket<--, -->Rocket<--, -->Rocket<--!', '10 -->Rocket<--!!!']

          # joined together again
          1 I heart -->Rocket<--!
          2 -->Rocket<--, -->Rocket<--, -->Rocket<--.
          4 -->Rocket<--, -->Rocket<--, -->Rocket<--!
          10 -->Rocket<--!!!



          If you want to confuse yourself you can do it as 4-liner:



          with open("k.txt") as f:
          text = "n".join(
          [f"row:2d x" for row,x
          in enumerate( f.read().replace("Rocket","-->Rocket<--").split("n"),1)
          if "Rocket" in x])
          print(text.count("Rocket"))
          print(text)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 29 at 7:57

























          answered Mar 27 at 22:08









          Patrick ArtnerPatrick Artner

          29.7k6 gold badges26 silver badges45 bronze badges




          29.7k6 gold badges26 silver badges45 bronze badges















          • That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

            – J.a. Martin
            Mar 28 at 23:15












          • @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

            – Patrick Artner
            Mar 29 at 7:56











          • Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

            – J.a. Martin
            Mar 29 at 21:18

















          • That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

            – J.a. Martin
            Mar 28 at 23:15












          • @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

            – Patrick Artner
            Mar 29 at 7:56











          • Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

            – J.a. Martin
            Mar 29 at 21:18
















          That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

          – J.a. Martin
          Mar 28 at 23:15






          That works well, thank you, but I am still having the issue of it labeling the line number for the highlight portion. The output should list the line number at the beginning example: 1: -->Rocket<--

          – J.a. Martin
          Mar 28 at 23:15














          @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

          – Patrick Artner
          Mar 29 at 7:56





          @j.a.martin use enumerate to enumerate the lines before excluding what does not match - see edit.

          – Patrick Artner
          Mar 29 at 7:56













          Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

          – J.a. Martin
          Mar 29 at 21:18





          Thank you so much for your help. I really appreciate it. I hope to be able to answer the questions sometime in the future.

          – J.a. Martin
          Mar 29 at 21:18






          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          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%2f55386983%2ftrouble-with-counting-and-highlights%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







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해