DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Swift: Master of Decoding Messy JSON
  • Secrets in Code: Understanding Secret Detection and Its Blind Spots
  • From HTTP to Kafka: A Custom Source Connector
  • Making String Search Easier Across Databases

Trending

  • Designing Agentic Systems Like Distributed Systems
  • Using LLMs to Automate Data Cleaning and Transformation Pipelines
  • Introduction to Retrieval Augmented Generation (RAG)
  • AI-Driven Integration in Large-Scale Agile Environments
  1. DZone
  2. Coding
  3. JavaScript
  4. Groovy Goodness: Check if a String Only Contains Whitespaces

Groovy Goodness: Check if a String Only Contains Whitespaces

By 
Hubert Klein Ikkink user avatar
Hubert Klein Ikkink
·
Sep. 12, 13 · Interview
Likes (0)
Comment
Save
Tweet
Share
12.9K Views

Join the DZone community and get the full member experience.

Join For Free

In Groovy we can check if a String value only contains whitespaces with the isAllWhitespace() method. The method checks for spaces, but also takes into account tab and newline characters as whitespace.

assert ''.allWhitespace
assert '  '.allWhitespace
assert '\t '.allWhitespace
assert ' \r\n '.allWhitespace

assert !'mrhaki'.allWhitespace
Groovy (programming language) Strings

Published at DZone with permission of Hubert Klein Ikkink. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Swift: Master of Decoding Messy JSON
  • Secrets in Code: Understanding Secret Detection and Its Blind Spots
  • From HTTP to Kafka: A Custom Source Connector
  • Making String Search Easier Across Databases

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook