Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. Regex search and replace? Tabs ...

Regex search and replace? Tabs ...

Scheduled Pinned Locked Moved Regular Expressions
toolsregexhelptutorialquestion
2 Posts 2 Posters 19 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14835146
    wrote on last edited by
    #1

    I have a regexp that works, in my software I search for timestamps with this: [01]?[0-9]:[0-5][0-9] and a macro replaces the carriage return with a tab and then I proceed from there. But it's very time-consuming when the timestamps go over 10 minutes as then 2 tabs are required (it's a weird thing but that's how it goes). 1. So, to outline, from 0:00 to 9:99 timestamps, one tab is needed afterwards. 2. But from 10:00 and up, i.e., timestamps like 22:46 and 1:35:05 for example, require 2 tabs aftewards. If it's any help, here is what my script looks like that goes through the entire document and deletes the carriage return and puts one tab after the timestamp (but where the timestamp needs one tab only between 0:00 and 9:99, then 2 tabs for larger timestamp times.

    document.selection.Find("[01]?[0-9]:[0-5][0-9]",eeFindNext | eeFindReplaceRegExp);
    document.selection.EndOfLine(false,eeLineView);
    document.selection.Text="\x09";
    document.selection.Delete(1);

    Thank you!

    J 1 Reply Last reply
    0
    • M Member_14835146

      I have a regexp that works, in my software I search for timestamps with this: [01]?[0-9]:[0-5][0-9] and a macro replaces the carriage return with a tab and then I proceed from there. But it's very time-consuming when the timestamps go over 10 minutes as then 2 tabs are required (it's a weird thing but that's how it goes). 1. So, to outline, from 0:00 to 9:99 timestamps, one tab is needed afterwards. 2. But from 10:00 and up, i.e., timestamps like 22:46 and 1:35:05 for example, require 2 tabs aftewards. If it's any help, here is what my script looks like that goes through the entire document and deletes the carriage return and puts one tab after the timestamp (but where the timestamp needs one tab only between 0:00 and 9:99, then 2 tabs for larger timestamp times.

      document.selection.Find("[01]?[0-9]:[0-5][0-9]",eeFindNext | eeFindReplaceRegExp);
      document.selection.EndOfLine(false,eeLineView);
      document.selection.Text="\x09";
      document.selection.Delete(1);

      Thank you!

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      Member 14835146 wrote:

      But it's very time-consuming

      That is not specific. As in it takes 10 seconds? Or 10 hours? Regexes meet specific needs but speed is not necessarily one of them. For starters a regex is always interpreted in the process. Even 'compiled' ones still end up in a form that is at best halfway to an actual compiled solution. And your problem is in fact something that likely could be solved by real code. So that is likely something that would be faster. But other than that it appears you might be attempting to do a regex solution for an entire file ('document') rather than doing it line by line. If you do in fact have lines which have a fixed number of timestamps then looping might provide a better solution especially if you can anchor the regex.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups