LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write a character string and find the number of vowels in it

Solved!
Go to solution

@Eric1977 wrote:

I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.

Same.  Kudos for the tip!

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 11 of 20
(520 Views)

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 20
(513 Views)

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 

Message 13 of 20
(470 Views)

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 14 of 20
(459 Views)

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow

0 Kudos
Message 15 of 20
(455 Views)

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow


I never thought of that.  Someone, somewhere probably made a regex for that!

 

OMG here's what ChatGPT came up with:

[aeiouAEIOUYy](?<![aeiouAEIOUy])[aeiouAEIOU]*$|(?<=[aeiouAEIOYy])y(?![aeiouAEIOUy])

 

Explanation:

  • [aeiouAEIOUYy] matches any vowel, including 'y' in both lowercase and uppercase.
  • (?<![aeiouAEIOUy])[aeiouAEIOU]*$ matches a vowel (excluding 'y') that is at the end of a word or syllable. The (?<![aeiouAEIOUy]) is a negative lookbehind that ensures there's no vowel or 'y' before the vowel we're matching.
  • (?<=[aeiouAEIOYy])y(?![aeiouAEIOUy]) matches 'y' that is surrounded by vowels (including 'y') in the middle of a syllable. The (?<=[aeiouAEIOYy]) is a positive lookbehind that ensures there's a vowel or 'y' before the 'y', and the (?![aeiouAEIOUy]) is a negative lookahead that ensures there's no vowel or 'y' after the 'y'.
Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 16 of 20
(448 Views)

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow


I never thought of that.  Someone, somewhere probably made a regex for that!

 

OMG here's what ChatGPT came up with:

[aeiouAEIOUYy](?<![aeiouAEIOUy])[aeiouAEIOU]*$|(?<=[aeiouAEIOYy])y(?![aeiouAEIOUy])

 

Explanation:

  • [aeiouAEIOUYy] matches any vowel, including 'y' in both lowercase and uppercase.
  • (?<![aeiouAEIOUy])[aeiouAEIOU]*$ matches a vowel (excluding 'y') that is at the end of a word or syllable. The (?<![aeiouAEIOUy]) is a negative lookbehind that ensures there's no vowel or 'y' before the vowel we're matching.
  • (?<=[aeiouAEIOYy])y(?![aeiouAEIOUy]) matches 'y' that is surrounded by vowels (including 'y') in the middle of a syllable. The (?<=[aeiouAEIOYy]) is a positive lookbehind that ensures there's a vowel or 'y' before the 'y', and the (?![aeiouAEIOUy]) is a negative lookahead that ensures there's no vowel or 'y' after the 'y'.

At a glance, it looks like it will check a word for vowels.

 

It doesn't seem to check vowels in a text. Or at least I don't see anything related to word barriers.

0 Kudos
Message 17 of 20
(445 Views)

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow


I never thought of that.  Someone, somewhere probably made a regex for that!

 

OMG here's what ChatGPT came up with:

[aeiouAEIOUYy](?<![aeiouAEIOUy])[aeiouAEIOU]*$|(?<=[aeiouAEIOYy])y(?![aeiouAEIOUy])

 

Explanation:

  • [aeiouAEIOUYy] matches any vowel, including 'y' in both lowercase and uppercase.
  • (?<![aeiouAEIOUy])[aeiouAEIOU]*$ matches a vowel (excluding 'y') that is at the end of a word or syllable. The (?<![aeiouAEIOUy]) is a negative lookbehind that ensures there's no vowel or 'y' before the vowel we're matching.
  • (?<=[aeiouAEIOYy])y(?![aeiouAEIOUy]) matches 'y' that is surrounded by vowels (including 'y') in the middle of a syllable. The (?<=[aeiouAEIOYy]) is a positive lookbehind that ensures there's a vowel or 'y' before the 'y', and the (?![aeiouAEIOUy]) is a negative lookahead that ensures there's no vowel or 'y' after the 'y'.

At a glance, it looks like it will check a word for vowels.

 

It doesn't seem to check vowels in a text. Or at least I don't see anything related to word barriers.


The rules I gave it related to a single word.  I forgot about that.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 18 of 20
(437 Views)

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow


I never thought of that.  Someone, somewhere probably made a regex for that!

 

OMG here's what ChatGPT came up with:

[aeiouAEIOUYy](?<![aeiouAEIOUy])[aeiouAEIOU]*$|(?<=[aeiouAEIOYy])y(?![aeiouAEIOUy])

 

Explanation:

  • [aeiouAEIOUYy] matches any vowel, including 'y' in both lowercase and uppercase.
  • (?<![aeiouAEIOUy])[aeiouAEIOU]*$ matches a vowel (excluding 'y') that is at the end of a word or syllable. The (?<![aeiouAEIOUy]) is a negative lookbehind that ensures there's no vowel or 'y' before the vowel we're matching.
  • (?<=[aeiouAEIOYy])y(?![aeiouAEIOUy]) matches 'y' that is surrounded by vowels (including 'y') in the middle of a syllable. The (?<=[aeiouAEIOYy]) is a positive lookbehind that ensures there's a vowel or 'y' before the 'y', and the (?![aeiouAEIOUy]) is a negative lookahead that ensures there's no vowel or 'y' after the 'y'.

At a glance, it looks like it will check a word for vowels.

 

It doesn't seem to check vowels in a text. Or at least I don't see anything related to word barriers.


The rules I gave it related to a single word.  I forgot about that.


AI or not, it's still a computer 😂...

0 Kudos
Message 19 of 20
(418 Views)

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

wiebe@CARYA wrote:

@billko wrote:

@Eric1977 wrote:

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.


I guess it gets more complicated if you add "sometimes 'y'".


Yes, but not by much:

wiebeCARYA_0-1692775848908.png

Since the entire match is a capturing group (the first) we can replace the match with itself (indicated by "$1"). 


But "y" is only a vowel (in the US) under certain conditions.


Ah, didn't know that.

 

That would make a funky regex.

 

But if there is one online, it will work.

 

Here's a discussion about vowels vs consonants regex's, but I don't think that covers it all: Regex - matching world which contain only vowels or consonants - Stack Overflow


I never thought of that.  Someone, somewhere probably made a regex for that!

 

OMG here's what ChatGPT came up with:

[aeiouAEIOUYy](?<![aeiouAEIOUy])[aeiouAEIOU]*$|(?<=[aeiouAEIOYy])y(?![aeiouAEIOUy])

 

Explanation:

  • [aeiouAEIOUYy] matches any vowel, including 'y' in both lowercase and uppercase.
  • (?<![aeiouAEIOUy])[aeiouAEIOU]*$ matches a vowel (excluding 'y') that is at the end of a word or syllable. The (?<![aeiouAEIOUy]) is a negative lookbehind that ensures there's no vowel or 'y' before the vowel we're matching.
  • (?<=[aeiouAEIOYy])y(?![aeiouAEIOUy]) matches 'y' that is surrounded by vowels (including 'y') in the middle of a syllable. The (?<=[aeiouAEIOYy]) is a positive lookbehind that ensures there's a vowel or 'y' before the 'y', and the (?![aeiouAEIOUy]) is a negative lookahead that ensures there's no vowel or 'y' after the 'y'.

At a glance, it looks like it will check a word for vowels.

 

It doesn't seem to check vowels in a text. Or at least I don't see anything related to word barriers.


The rules I gave it related to a single word.  I forgot about that.


AI or not, it's still a computer 😂...


I know.  It did exactly what I told it to do, which may or may not be what I wanted it to do.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 20 of 20
(380 Views)