regex

Find and replace regex in Intellij, but keep some of the matched regex?

99封情书 提交于 2021-01-18 02:48:45
问题 I changed an array to a list, so I want to change all instances of myObject[index] to myObject.get(index) where index is different integers. I can find these instances by doing `myObject\[.*\]` However, I am not sure what I should put in the replace line - I don't know how to make it keep the index values. 回答1: Use the following regex replacement: Find : myObject\[(.*?)\] Replace : myObject.get($1) If the index is an integer, you may replace (.*?) with (\d+) . The pair of unescaped

Creating Array of Regular Expressions Javascript

为君一笑 提交于 2021-01-16 08:42:29
问题 I want to create a function that compares a password against some commonly idiotic ones, so that the user can't pick one of these, but the function I have written so far, when put between script tags, causes no javascript to be recognized (by Firebug). I assume the array creation is at fault. function unacceptable(pwd){ var unforgivable = [ /password/gi, /*g matches any occurance of sequence, i checks case insensitive*/ /12345678/g, /8675309/g, /[a-z]{8,}/gi, /qwerty/gi, /asdfg/gi, /qazwsx/gi

java常用API

扶醉桌前 提交于 2021-01-15 07:00:23
1、Java API概述 java写好的包 类 方法的使用—API Application Programing Interface:应用程序编程接口。java提供的一些预定义的函数目的:基于API实现程序的快速编写。只需了解实现的作用,无需关注源代码 针对一个API首先看 概述了解 类的作用,然后看 构造函数了解如何创建类之后看方法,了解如何调用 java lang–核心包 提供对Java编程语言设计至关重要的类,可以直接使用,不用import 2、数值运算 Math类 Math类为java提供的支持数值运算的类 Math类包含执行基本数字运算的方法,如基本指数,对数,平方根和三角函数 public final class Math—-完美类 (1)Math类提供的基本方法: static double abs(double a) 返回值为 double绝对值 static double acos(double a) 返回值的反余弦值; 返回的角度在0.0到pi的范围内 static double atan(double a) 向上取整: static double ceil(double a) 返回大于或等于参数的最小(最接近负无穷大) double值,等于一个数学整数 向下取整: static double floor(double a) 返回小于或等于参数的最大

Django url that captures yyyy-mm-dd date

夙愿已清 提交于 2021-01-14 16:36:13
问题 How do you capture a url that contains yyyy-mm-dd in Django. So like www.mydomain.com/2011-02-12. I tried: url(r'^(?P<date>\d{4}-\d{2}-\d{2})/$', views.index, name='index'), But, the server says page not found. 回答1: You should have a group name in the url pattern: url(r'^(?P<date>\d{4}-\d{2}-\d{2})/$', views.index, name='index'), # ^^^^ Also pay attention to the trailing slash in the url: www.mydomain.com/2011-02-12/ . If you don't want a slash in the url, you can remove it from the pattern.

Django url that captures yyyy-mm-dd date

醉酒当歌 提交于 2021-01-14 16:33:11
问题 How do you capture a url that contains yyyy-mm-dd in Django. So like www.mydomain.com/2011-02-12. I tried: url(r'^(?P<date>\d{4}-\d{2}-\d{2})/$', views.index, name='index'), But, the server says page not found. 回答1: You should have a group name in the url pattern: url(r'^(?P<date>\d{4}-\d{2}-\d{2})/$', views.index, name='index'), # ^^^^ Also pay attention to the trailing slash in the url: www.mydomain.com/2011-02-12/ . If you don't want a slash in the url, you can remove it from the pattern.

Java/Python/Elixir 正则库使用上的注意事项

穿精又带淫゛_ 提交于 2021-01-14 04:53:45
个人笔记,写得乱。。不过自己看得懂就行了—_— 日常工作中能接触到的正则,分为两大派别,其中 Unix-Like 系统中常用的正则,属于 POSIX “派”(较弱),而各编程语言标准库中的 Re,基本都是 PCRE “派”。(详见 正则表达式“派别”简述 ) 可虽然说各编程语言基本都属于 PCRE 派,实现上却还是各有特点,一个正则想在各语言间移植,也往往需要一番修改。 今天学 Elixir,就在正则上遇到了问题,百度一番,想想索性就把这些差别总结一遍,防止下次又掉坑里。(包括 Python、Java、Elixir、文本编辑器的正则,有时间把 SQL 的正则也写写。。) 一、正则库方法上的差别 1.1 模式匹配 文本编辑器的正则 是用来搜索的 ,会匹配 整段文本中所有符合该模式的字符串 ,可以叫做 find all 。 而不同的编程语言,又要看方法设计上的理念差别: Python 提供了以下方法 match:要求必须从字符串开头开始尝试匹配,相当与使用了 PCRE 的 anchored(锚定)模式。(或者说自动在正则开头添加了 \A ,它在 Python 中表示字符串开头) fullmatch:要求必须匹配整个字符串,相当于在正则的开头添加 \A ,末尾添加 \Z (它在 Python 中表示字符串末尾). search:从字符串中搜索该模式,找到第一个就返回。 findall

Regex to find not start and end with dot and allow some special character only not all

你。 提交于 2021-01-13 10:02:18
问题 I am trying to match a string which is not start and and with (.)dot and allow some special char like underscore(_) in string i found dot match regex but not able to match special character what i have done preg_match('/^(?![.])(?!.*[.]$).*$/', $str) Not allowed .example example. example?ghh. (or some more special char not allowed in string) allowed exam.pl56e exmple_ _example_ exam_ple So string will be 1. Not start with dot but in the middle can be a dot(.) 2. String Not allow special char

Regex to find not start and end with dot and allow some special character only not all

狂风中的少年 提交于 2021-01-13 10:00:47
问题 I am trying to match a string which is not start and and with (.)dot and allow some special char like underscore(_) in string i found dot match regex but not able to match special character what i have done preg_match('/^(?![.])(?!.*[.]$).*$/', $str) Not allowed .example example. example?ghh. (or some more special char not allowed in string) allowed exam.pl56e exmple_ _example_ exam_ple So string will be 1. Not start with dot but in the middle can be a dot(.) 2. String Not allow special char

Regex to find not start and end with dot and allow some special character only not all

走远了吗. 提交于 2021-01-13 09:59:28
问题 I am trying to match a string which is not start and and with (.)dot and allow some special char like underscore(_) in string i found dot match regex but not able to match special character what i have done preg_match('/^(?![.])(?!.*[.]$).*$/', $str) Not allowed .example example. example?ghh. (or some more special char not allowed in string) allowed exam.pl56e exmple_ _example_ exam_ple So string will be 1. Not start with dot but in the middle can be a dot(.) 2. String Not allow special char

Django 之 ORM 字段和字段参数

左心房为你撑大大i 提交于 2021-01-13 09:50:47
ORM介绍 ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术。 简单的说,ORM是通过使用描述对象和数据库之间映射的元数据,将程序中的对象自动持久化到关系数据库中。 ORM在业务逻辑层和数据库层之间充当了桥梁的作用。 ORM的优势 ORM解决的主要问题是对象和关系的映射。它通常把一个类和一个表一一对应,类的每个实例对应表中的一条记录,类的每个属性对应表中的每个字段。 ORM提供了对数据库的映射,不用直接编写SQL代码,只需像操作对象一样从数据库操作数据。 让软件开发人员专注于业务逻辑的处理,提高了开发效率。 ORM的劣势 ORM的缺点是会在一定程度上牺牲程序的执行效率。 ORM用多了SQL语句就不会写了,关系数据库相关技能退化... ORM基本表结构 from django.db import models class userinfo(models.Model): name = models.CharField(max_length=30 ) email = models.EmailField() memo = models.TextField() Django中的ORM Django项目使用MySQL数据库 1. 在Django项目的settings.py文件中