2023-05-25 17:47:19 +02:00
|
|
|
# Lösung: Reguläre Ausdrücke: Match
|
2023-05-23 09:19:31 +02:00
|
|
|
|
2023-05-25 17:49:42 +02:00
|
|
|
|
|
|
|
```ruby
|
2023-05-25 17:47:19 +02:00
|
|
|
def tag?(text)
|
|
|
|
!!(/^<.*?>$/ =~ text)
|
2023-05-23 09:19:31 +02:00
|
|
|
end
|
|
|
|
|
2023-05-25 17:47:19 +02:00
|
|
|
tag?("<a href='xx'>") # -> true
|
|
|
|
tag?("hugo <jjj>") # -> false
|
|
|
|
tag?("<a href='xx'") # -> false
|
|
|
|
tag?("<p/>") # -> true
|
|
|
|
tag?("<p") # -> false
|
|
|
|
tag?("p>") # -> false
|
|
|
|
```
|