Welcome Guest

Pages: 1
Regex uppercase text replacement
Gary-SwiftPostNovember 17, 2024, 07:43
Advanced
Posts: 70
Registered:
April 29, 2014, 06:12
Normal topicRegex uppercase text replacement

I'm trying and failing to make the first character in the comment field uppercase.

I am able to get the character using a simple regex but I can't get Yate to make the replacement uppercase.

I expected to use \U before the variable replacement but this just adds the U character.

Any ideas, or other ways to do this?

Image

2MR2PostNovember 17, 2024, 10:46
Avatar photo
Administrator
Posts: 2362
Registered:
August 23, 2012, 19:27
Normal topicRegex uppercase text replacement

\U is not an ICU sequence and as such is not supported by Apple's regex implementation.

Replace the highlighted line (13) with:

Substring [0, 1] of Comments -> Variable 0
Case Capitalize in Variable 0
Remove "1" character at index "0" from the beginning then insert "\v0" at index "0" from the beginning in field Comments

There is however still an issue. The test on line 15 does not account for multiple files with different Comments fields. (Yate's parallel operations)

You could change lines 15-18 with the following:

Test if the Comments field ends with "." (Set test state and Variable 1)
if Variable 1 is false
Append "." to the Comments field
endif

or you could simply replace 15-18 with:

Find first match for regular expression "\.*$" in field Comments, replace with "." to field Comments.

Gary-SwiftPostNovember 18, 2024, 14:14
Advanced
Posts: 70
Registered:
April 29, 2014, 06:12
Normal topicRegex uppercase text replacement

That is great, thank you.

There is however still an issue. The test on line 15 does not account for multiple files with different Comments fields. (Yate's parallel operations)

Noted. This is not the first time I have forgotten about this.

Gary-SwiftPostNovember 18, 2024, 14:58
Advanced
Posts: 70
Registered:
April 29, 2014, 06:12
Normal topicRegex uppercase text replacement

Thanks. I've updated this to include a "Test if all loaded files are in the same folder" rule and changed it to use substring and insert. It's working exactly as I wanted now.

Image

2MR2PostNovember 18, 2024, 15:02
Avatar photo
Administrator
Posts: 2362
Registered:
August 23, 2012, 19:27
Normal topicRegex uppercase text replacement

Great. This'll work as long as the comments are the same for every file in the folder. That may be the case for files in the same folder. 🙂

Gary-SwiftPostNovember 18, 2024, 15:15
Advanced
Posts: 70
Registered:
April 29, 2014, 06:12
Normal topicRegex uppercase text replacement

Yeah, that's generally what I do. The comment field is usually the same and it's how I intend to use this.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.031 seconds.