mitcanmit
mitcanmit

Reputation: 5

Regular expression= tabspace+STRING+tabspace

How can I write this as a regular expression?

tabspaceSTRINGtabspace

My data looks like this:

12345   adsadasdasdasd  30
34562   adsadasdasdasd  asdadaads<adasdad   30
12313   adsadasdasdasd  asdadas dsaads  313123<font="TNR">adsada    30
1232131 adsadasdasdasd  asdadaads<adasdad"asdja <div>asdjaıda   30

I want to get

12345   30
34562   30
12313   30
1232131 30

\t*\t doesn't work.

Upvotes: 0

Views: 220

Answers (4)

Sebastian vom Meer
Sebastian vom Meer

Reputation: 5241

If you are not sure about the strings you are looking for except that they are separated by tabs it is a good approach to describe such a string as everything but a tab: (^\t*)

[^\t]*\t([^\t]*)\t[^\t]*

You can test it on regexpad.com.

Upvotes: 0

stema
stema

Reputation: 93026

What characters are allowed in your string?

\t\w+\t

\w would allow letters, digits and the underscore (depending on your regex engine ASCII or Unicode)

See it here on Regexr, a good platform to test regular expressions.

Your "regex" \t*\t would match 0 or more tabs and then one tab. The * is a quantifier meaning 0 or more and is referring to the character or group before (here to your \t)

If your whitespace are not tabs, try this

\s+.+\s+30

\s is a whitespace character (space, tab, newline (not important for Notepad++)).

Upvotes: 0

pcalcao
pcalcao

Reputation: 15990

The problem there is your definition of String...

If you use something like the suggested above, it'll match

tabspaceSTRINGtabspacetabspace

You get the picture. This might be acceptable, if not, you need to limit your "STRING" definition, like:

\t\w+\t

or:

\t[a-zA-Z]+\t

Upvotes: 0

juergen d
juergen d

Reputation: 204884

try the following regular expression

\t.+\t

Upvotes: 1

Related Questions