首页 > 原创文章 > 软件开发 > 查看文章

JS/Php/Java/Python常用语法及函数

所属分类:软件开发 来源: 丁老师原创 更新时间:2025-10-22 08:36 浏览: 1734 IP属地: 深圳
微信小程序开发

js

#replace替换
var str="Hello world! world is beautiful.";
var str_new=str.replace("world","JavaScript");
console.log(str_new);

#替换全部
var str="Apple, Banana, Apple, Orange";
const str_new=str.replace(/Apple/g,"Grape");
console.log(str_new); 

#忽略大小写
const str_new= str.replace(/hello/gi,"Hi");

#In Arrray
const arr=['apple','banana','cherry'];
console.log(arr.includes('banana'));

php

#replace
$str="Hello world! world is beautiful.";
$str_new=str_replace("world","PHP",$str);
echo $str_new; 

#忽略大小写
$str="Hello HELLO hello";
$str_new=preg_replace('/hello/i','Hi',$str);
echo $str_new;

#in_array
$arr=['apple','banana','cherry'];
in_array('banana',$arr);

java

#replace
String str="Hello world! world is beautiful.";
String str_new=str.replace("world", "Java");
System.out.println(str_new);

#in array
String[] arr={"apple", "banana", "cherry"};
List<String> list=Arrays.asList(arr); 

System.out.println(list.contains("banana"));

python

#replace
s="Hello world! world is nice."
s_new=s.replace("world", "Python")
print(new_s)

#in array
arr=['apple', 'banana', 'cherry']
print('banana' in arr)

相关文章

Composer更新指定包

composer更新指定包的命令composer require alibabacloud/dysmsapi-20170525:2.0.24 --ignore-platform-reqs composer update alibabac...

使用C#读取Excel文件内容的两种方法

使用c#读取excel文件可以通过OleDbDataAdapter来进行读取,将excel文件作为数据库,以检索数据的方式来读取excel内容。具体代码如下:var fileName = string.Format("{0}...

微信企业付款到零钱开发

丁老师开发的微信企业付款功能,可以直接对接系统,在用户申请提现时由微信直接付款至个人的微信零钱账户

C#开发的Winform程序如何把dll放到...

有同学咨询,使用Visual Studio工具C#开发的Winform程序,生成后软件目录全是大量dll文件,看起来杂乱无章,有没有什么办法能让他统一放到一个文件夹里边呢?丁老师对此问题进行解答。为什么会产生大量的dll文件?因为在使用...

推荐文章

性价比最高的内网穿透方案

内网穿透,是指外网可以访问内网,没有固定IP的服务器,所以需要中间件来进行通讯,目前稳定成熟的中间件软件,要么价格太贵,要么就是只能使用标准服务,不能完全的定制化。那么,到底有没有一个性价比最优的方案呢?回答是肯定的,答案就是使用云服务器+...

CodeIgniter框架URL如果去掉in...

在使用PHP框架CI时,有个很恶心的地方就是他的URL需要带上index.php,比如我要建一个user模块,想要实现www.xxx.com/user/的效果,但是在CI框架下必须要www.xxx.com/index.php/user这样才...

FastAdmin add/edit方法不更...

问题:fastadmin的add/edit方法无法保存数据,检查了页面,name=row['name']正常传送,检查controller,也是默认的方法,什么也没有动可就是无法保存数据。解决:经过仔细研究发现,原来是htm...

Tortoise Svn出现No Path ...

在日常开发过程中,突然发现svn无法提交和更新,出现“no path or pathfile specified on the command line”的错误,网上搜了一圈百度 google 以及stack overflow都没找到真正能...