Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,884 questions

51,810 answers

573 users

How to extract only words with first-letter lowercase from a string in VB.NET

3 Answers

0 votes
Imports System.Text.RegularExpressions
Imports System.Collections.Generic
Imports System

Public Class Program

    ' Function to extract words starting with lowercase
    Public Shared Function GetLowercaseWords(s As String) As List(Of String)
        Dim arr() As String = Regex.Split(s, "\W")
        Dim result As New List(Of String)

        For Each word In arr
            If Not String.IsNullOrEmpty(word) AndAlso Char.IsLower(word(0)) Then
                result.Add(word)
            End If
        Next

        Return result
    End Function

    Public Shared Sub Main()
        Dim s As String = "VB.NET c cpp Java Python php rust"

        Dim list As List(Of String) = GetLowercaseWords(s)

        For Each w In list
            Console.WriteLine(w)
        Next
    End Sub

End Class


' run:
'
' c
' cpp
' php
' rust

 



answered Feb 2, 2017 by avibootz
edited Jan 16 by avibootz
0 votes
Imports System
Imports System.Collections.Generic
  
Public Class program
    Friend Shared Function extract_only_words_with_first_letter_lowercase(ByVal s As String) As List(Of String)
        Dim words As List(Of String) = New List(Of String)()
        Dim start As Integer = 0
        Dim _end As Integer = s.IndexOf(" ", start, StringComparison.Ordinal)
          
        While (_end <> -1)
            Dim word As String = s.Substring(start, _end - start)
  
            If Char.IsLower(word(0)) Then
                words.Add(word)
            End If
  
            start = _end + 1
            _end = s.IndexOf(" ", start, StringComparison.Ordinal)
        End While
  
        If Char.IsLower(s.Substring(start)(0)) Then
            words.Add(s.Substring(start))
        End If
  
        Return New List(Of String)(words)
    End Function
  
    Public Shared Sub Main(ByVal args As String())
        Dim s As String = "VB .NET, is a Multi-paradigm, object-oriented pRogramming language"
          
        Dim words As List(Of String) = extract_only_words_with_first_letter_lowercase(s)
  
        For Each w As String In words
            Console.WriteLine(w)
        Next
    End Sub
End Class
  
  
  
  
' run:
'
' is
' a
' object-oriented
' pRogramming
' language
'

 



answered Apr 13, 2024 by avibootz
0 votes
Imports System
Imports System.Collections.Generic
 
Public Class program
    Friend Shared Function extract_only_words_with_first_letter_lowercase(ByVal s As String) As List(Of String)
        Dim lowercase As List(Of String) = New List(Of String)()
        Dim words As String() = s.Split(" "c)
 
        For Each word In words
            If Char.IsLower(word(0)) Then
                lowercase.Add(word)
            End If
        Next
 
        Return New List(Of String)(lowercase)
    End Function
 
    Public Shared Sub Main(ByVal args As String())
        Dim s As String = "VB .NET, is a Multi-paradigm, object-oriented pRogramming language"
          
        Dim words As List(Of String) = extract_only_words_with_first_letter_lowercase(s)
  
        For Each w As String In words
            Console.WriteLine(w)
        Next
    End Sub
End Class
  
  
  
  
' run:
'
' is
' a
' object-oriented
' pRogramming
' language
'

 



answered Apr 13, 2024 by avibootz

Related questions

...