Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
11
Task/Regular-expressions/ABAP/regular-expressions.abap
Normal file
11
Task/Regular-expressions/ABAP/regular-expressions.abap
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
DATA: text TYPE string VALUE 'This is a Test'.
|
||||
|
||||
FIND FIRST OCCURRENCE OF REGEX 'is' IN text.
|
||||
IF sy-subrc = 0.
|
||||
cl_demo_output=>write( 'Regex matched' ).
|
||||
ENDIF.
|
||||
|
||||
REPLACE ALL OCCURRENCES OF REGEX '[t|T]est' IN text WITH 'Regex'.
|
||||
|
||||
cl_demo_output=>write( text ).
|
||||
cl_demo_output=>display(
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
str = "This is a string"
|
||||
if str =~ ~r/string$/, do: IO.inspect "str ends with 'string'"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
str =~ ~r/this/ # => false
|
||||
str =~ ~r/this/i # => true
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
str1 = ~r/a/ |> Regex.replace(str,"another")
|
||||
str2 = str1 |> String.replace(~r/another/,"even another")
|
||||
|
|
@ -0,0 +1 @@
|
|||
str3 = ~r/another/ |> Regex.replace(str2, fn x -> "#{String.upcase(x)}" end)
|
||||
18
Task/Regular-expressions/Emacs-Lisp/regular-expressions.l
Normal file
18
Task/Regular-expressions/Emacs-Lisp/regular-expressions.l
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(defun match (word str)
|
||||
(setq pos (string-match word str) )
|
||||
(if pos
|
||||
(progn
|
||||
(insert (format "%s found at position %d in: %s\n" word pos str) )
|
||||
(setq regex (format "^.+%s" word) )
|
||||
(setq str (replace-regexp-in-string regex (format "left %s" word) str) )
|
||||
(setq regex (format "%s.+$" word) )
|
||||
(setq str (replace-regexp-in-string regex (format "%s right" word) str) )
|
||||
(insert (format "result: %s\n" str) ))
|
||||
(insert (format "%s not found in: %s\n" word str) )))
|
||||
|
||||
(setq str1 "before center after" str2 "before centre after")
|
||||
|
||||
(progn
|
||||
(match "center" str1)
|
||||
(insert "\n")
|
||||
(match "center" str2) )
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
var subject = "Hello world!";
|
||||
|
||||
// Two different ways to create the RegExp object
|
||||
// Both examples use the exact same pattern... matching "hello"
|
||||
// Both examples use the exact same pattern... matching "hello "
|
||||
var re_PatternToMatch = /Hello (World)/i; // creates a RegExp literal with case-insensitivity
|
||||
var re_PatternToMatch2 = new RegExp("Hello (World)", "i");
|
||||
|
||||
|
|
|
|||
9
Task/Regular-expressions/VBScript/regular-expressions.vb
Normal file
9
Task/Regular-expressions/VBScript/regular-expressions.vb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
text = "I need more coffee!!!"
|
||||
Set regex = New RegExp
|
||||
regex.Global = True
|
||||
regex.Pattern = "\s"
|
||||
If regex.Test(text) Then
|
||||
WScript.StdOut.Write regex.Replace(text,vbCrLf)
|
||||
Else
|
||||
WScript.StdOut.Write "No matching pattern"
|
||||
End If
|
||||
Loading…
Add table
Add a link
Reference in a new issue