Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove blank lines: tabs, spaces, (\s) using regex
#1
Sorry for this very simple question.
But I have a lot of trouble tackling this seemingly very simple request:

A string
Code:
Copy      Help
abc


def

The line(s) between between abc and def must be removed IF it contains:
- one or more spaces / one or more ALT+255 chars (nbsp)
- one or more tabs
- one or more ENTERS / SHIFT+ENTERS

It can be a combination of the above

I have tried many regexes containing:
But it constantly creates 1 line (see below) OR it does nothing and thus keeping the original result
Code:
Copy      Help
abcdef

in stead of the desired result:
Code:
Copy      Help
abc
def


How I build the regex:

- I always start the regex by placing the cursor at the beginning by using: ^

Then I follow with

- zero or more spaces: \s*
- zero or more tabs: \t*
- followed at the end by a carriage return and newline: \r\n

I combined that with the previous mentioned: $ ,\w , [] but I end up with all on one line OR no changes at all.
This is really weird for me, because I have solved complexer regexes much easier in QM.
But this simple thing I cannot solve.
(also tried regexes from stackoverflow.com, but also constantly no result or everything on one line)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)