Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View 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(

View file

@ -0,0 +1,2 @@
str = "This is a string"
if str =~ ~r/string$/, do: IO.inspect "str ends with 'string'"

View file

@ -0,0 +1,2 @@
str =~ ~r/this/ # => false
str =~ ~r/this/i # => true

View file

@ -0,0 +1,2 @@
str1 = ~r/a/ |> Regex.replace(str,"another")
str2 = str1 |> String.replace(~r/another/,"even another")

View file

@ -0,0 +1 @@
str3 = ~r/another/ |> Regex.replace(str2, fn x -> "#{String.upcase(x)}" end)

View 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) )

View file

@ -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");

View 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