Skip to content

Instantly share code, notes, and snippets.

@josuigoa
Last active October 26, 2017 11:19
Show Gist options
  • Save josuigoa/96f1654ee0e6df7435c93cbfd14d49c7 to your computer and use it in GitHub Desktop.
Save josuigoa/96f1654ee0e6df7435c93cbfd14d49c7 to your computer and use it in GitHub Desktop.
Adierazpen erregularrak
class AE {
static public inline var lerro_saltoa = ~/\r?\n/g;
static public inline var zuriunea = ~/[\t|\s]+/g;
// ONARTUAK: 1985/08/21 / 1982/2/24 / 2013/12/3
// EZ ONARTUAK: 1/3/14 / 01/09/16 / 21/08/1958
// data_osoa = data.matched(0); // 1985/08/21
// urtea = data.matched(1); // 1985
// hilabetea = data.matched(2); // 08
// eguna = data.matched(3); // 21
static public inline var data_eu = ~/([0-9]{4,4})\/([0-9]{1,2})\/([0-9]{1,2})/g;
static public inline var data = ~/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4,4})/g; // 8/21/1985 / 21/8/1985
// ONARTUAK: 10:32 / 9:04 / 13:27:19
// EZ ONARTUAK: 10:9 / 11:2 / 10:32:8
// ordu_osoa = ordua.matched(0); // 13:27:19
// ordua = ordua.matched(1); // 13
// minutua = ordua.matched(2); // 27
// segundua = ordua.matched(4); // 19
static public inline var ordua = ~/([0-9]{1,2}):([0-9]{2,2})(:([0-9]{2,2}))?/g;
// ONARTUAK: id='proba' / id="proba" / id='proba_01' / id='proba-01'
// EZ ONARTUAK: id=proba / id="proba 01" / class="proba bat"
// osoa = id_attr.matched(0); // id='proba_01'
// id = id_attr.matched(1); // proba_01
static public inline var id_attr = ~/id=(["']([A-Za-z0-9_-]+)["'])/;
// ONARTUAK: class='proba ezkutua' / class="proba" / class='probatarako da klase-multzo hau'
// EZ ONARTUAK: class=proba / id="proba 01"
// osoa = class_attr.matched(0); // class='proba ezkutua'
// klaseak = class_attr.matched(1); // proba ezkutua
static public inline var class_attr = ~/class=["']([A-Za-z0-9_\s-]+)["']/;
// ONARTUAK: <h1> / <h1 class="titulua"/>
// EZ ONARTUAK: < h1>
// osoa = tag.matched(0); // <h1 class="titulua"/>
// etiketa = tag.matched(1); // h1
static public inline var tag = ~/<([A-Za-z0-9]+)/;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment