Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ================================================================================
- StringUnit::String
- ================================================================================
- php code
- ============================================================================
- <?PHP
- $string = new String('foobar');
- print $string->toString();
- ?>
- ============================================================================
- result
- generic string-object
- ============================================================================
- String::__set_state(array(
- '__copy' => 'foobar',
- '__hash' => '255c71d6',
- '__buffer' => '',
- '__type' =>
- Type::__set_state(array(
- '__type' => 'String',
- '__isArray' => false,
- '__isPrimitive' => true,
- '__isLocked' => false,
- '__isCountable' => false,
- '__isIterator' => false,
- '__locktrace' =>
- array (
- ),
- )),
- '__buffer' => 'foobar',
- ))
- ============================================================================
- ================================================================================
- StringUnit::trimStart
- ================================================================================
- php code
- ============================================================================
- <?PHP
- $code = array
- (
- "using System;",
- "",
- "public class HelloWorld",
- "{",
- " public static void Main()",
- " {",
- " // This code displays a simple greeting",
- " // to the console.",
- " // test:",
- " // / ",
- " Console.WriteLine(\"Hello, World.\");",
- " }",
- "}"
- );
- ?>
- ============================================================================
- php code
- ============================================================================
- <?PHP
- $lines = new StringArray($code);
- $lines->rightJoin(new String("\n"));
- foreach($lines as $line)
- print $line->get();
- ?>
- ============================================================================
- result
- before strip comments
- ============================================================================
- using System;
- public class HelloWorld
- {
- public static void Main()
- {
- // This code displays a simple greeting
- // to the console.
- // test:
- // /
- Console.WriteLine("Hello, World.");
- }
- }
- ============================================================================
- php code
- ============================================================================
- <?PHP
- $comment = new String('//');
- $replace = new String('/ ');
- $lines = new StringArray($code);
- $lines
- ->rightJoin(new String("\n"))
- ->trimStart();
- foreach($lines as $line)
- if($line->startsWith($comment)->get() === true)
- print $line->trimStart($replace)->get();
- ?>
- ============================================================================
- result
- extracted comments
- ============================================================================
- This code displays a simple greeting
- to the console.
- test:
- /
- ============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement