You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
myString = "A;B;C;D;E"
myPieces = myString.split(";") # erzeugt ein Arrey mit den einzelnen Zeichen
print myPieces[2] # gibt C aus
236
MySQL
Strings
String nach Delimenter zerlegen
-- Not a real solution, but a workaround if you have rights to create a function
-- see: http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/
-- same problem with MSSQL.
CREATE FUNCTION SPLIT_STR(
StringToBeSplitted VARCHAR(255),
delimiter VARCHAR(12),
position INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(StringToBeSplitted, delimiter, position),
LENGTH(SUBSTRING_INDEX(StringToBeSplitted, delimiter, position -1)) + 1),
delimiter, '');
SELECT SPLIT_STR(string, delimiter, position);
34
Caché
Caché-Spezifisch, Prozesse/Jobs
Variableninhalt eines fremden Prozesses ermitteln
; Important: You musn't check variables in your own job, it will result in a <PARAMETER>-Error!
Set checkjob=1234
Set checkvar="foo"
; Check if job is not my own
Quit:checkjob=$Job
; Check if Job exists und prompt the content of the varible foo
If $Data(^$Job(checkjob)) W !,$ZUtil(88,2,checkjob,checkvar)
; Prompts the content of the variable foo, maybe it is 'bar' ;-)
35
Java
GUI, Komponenten allgemein
Focus setzen
jTextfield1.requestFocus();
36
Java
GUI, Komponenten allgemein
Panel Größe ändern
import java.awt.Dimension;
import javax.swing.JPanel;
Dimension dim = new Dimension();
dim.height=300;
dim.width=500;
JPanel pan = new JPanel();
pan.setPreferredSize(dim);
37
Java
GUI, Komponenten allgemein
L&F setzen/ändern
import javax.swing.UIManager;
// Set the L&F to the standard OS-Theme
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// there are other possibilites and L&F-Sets... Just google ;-)
// For example look at L2FProd or Substance...
38
PHP
Array
Über alle Array-Elemente interieren
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
foreach ($arr as $key => $value) {
echo "{$key} => {$value} ";
}
301
PL/pgSQL
Array
Über alle Array-Elemente interieren
DO
$do$
DECLARE
m text[];
arr text[] := '{{key1,val1},{key2,val2}}'; -- array literal
BEGIN
FOREACH m SLICE 1 IN ARRAY arr
LOOP
RAISE NOTICE 'another_func(%,%)', m[1], m[2];
END LOOP;
END
$do$;
-- ---------------------------------------------------------
DO
$do$
DECLARE
i text;
arr text[] := '{key1,key2}'; -- array literal
BEGIN
FOREACH i IN ARRAY arr
LOOP
RAISE NOTICE 'another_func(%)', i;
END LOOP;
END
$do$;
39
PHP
Strings
String nach einem Teilstring durchsuchen
// is case sensitiv
// use stristr for case insensitive
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // Ausgabe: @example.com
$user = strstr($email, '@', true); // Ab PHP 5.3.0
echo $user; // Ausgabe: name
40
Mumps
Strings
String nach einem Teilstring durchsuchen
Set fullstring="This is my string"
Set searchfor="my"
If $Find(fullstring, searchfor) Do
. Write !,"I found it!!"
. Quit