WR7500
WR7500

Reputation: 449

How can I select only the first occurance of a specific character using regex?

I'm trying to match only the T character in the string below, which is between the date and timestamp.

"2016-04-28T13:57:02","3055551269","Incoming","Text","0.0"

I can find the grouping of numbers, with the T in the middle using \d[T]\d, but I can't seem to figure out how to capture only the first instance of T

Essentially, I'm trying to replace this character with a , in Notepadd++ to properly format a CSV file.

Upvotes: 2

Views: 46

Answers (2)

Shubham Sharma
Shubham Sharma

Reputation: 1831

Use -

      ^([^T]*)T

What it means is:-

From the start of String , don't include word until first T comes.

[^T] means do not include T

'*' means zero or more occurrences.

T means first occurace of T

Upvotes: 0

anubhava
anubhava

Reputation: 785306

You can use negated character class for this. Use this regex to search:

^([^T]*)T

And for replace use:

\1,

RegEx Demo

Upvotes: 2

Related Questions