Code Explainers

Code explainers tagged #edge-cases

php
<?php
 
class NameParser
{

Parsing a full name into components in PHP

string-parsing arrays normalization
Intermediate 8 steps
ruby
def wrap_text(text, width = 80)
  raise ArgumentError, "width must be positive" unless width.positive?
 
  text.split(/\n/, -1).map do |paragraph|

How greedy text wrapping works in Ruby

string-processing greedy-algorithm text-wrapping
Intermediate 7 steps
typescript
interface ParsedName {
  first: string;
  middle: string;
  last: string;

Parsing human names into structured parts

parsing string-manipulation normalization
Intermediate 9 steps
javascript
function splitFullName(fullName) {
  const cleaned = (fullName || '').trim().replace(/\s+/g, ' ');
 
  if (!cleaned) {

Parsing full names into first and last

string-parsing regex edge-cases
Intermediate 8 steps