首页 \ 问答 \ 从字符串中删除特定的出现(Remove specific occurence from string)

从字符串中删除特定的出现(Remove specific occurence from string)

我有一个名为$name的变量,它包含项目的名称。 在大多数情况下,名称采用以下形式

OCT16: Some Project

但是,它并不总是采用这种格式,有时它没有月/年前缀。

我试图做的是这个。 如果它有前缀MMMYY:那么我需要从名称中删除此部分。 现在我知道我可以使用像preg_replace这样的东西来从字符串中删除这个特定的模式,但是我如何检查它是否具有这种模式呢?

任何建议表示赞赏

谢谢


I have a variable called $name that contains the name of a project. In most cases, the name takes the following form

OCT16: Some Project

However, it is not always in this format, sometimes it does not have the month/year prefix.

What I am attempting to do is this. If it does have the prefix MMMYY: then I need to remove this part from the name. Now I know I could probably use something like preg_replace to remove this particular pattern from a string, but how do I check that it has this pattern in the first place?

Any advice appreciated.

Thanks


原文:https://stackoverflow.com/questions/40153331
更新时间:2019-12-22 21:12

最满意答案

多引导规范说:

Multiboot标头必须完全包含在OS映像的前8192字节内,并且必须是长字(32位)对齐。

objdump给了我们:

Idx Name              Size      File off  Algn
  3 .multiboot_header 00000018  00000040  2**0 CONTENTS, READONLY

注意Algn=2**0

解决方案:指定对齐:

.section .multiboot_header
.balign 4
header_start:

这应该也适用于nasm版本,由于文件布局,它只是偶然的。


The multiboot specification says:

The Multiboot header must be contained completely within the first 8192 bytes of the OS image, and must be longword (32-bit) aligned.

objdump gives us:

Idx Name              Size      File off  Algn
  3 .multiboot_header 00000018  00000040  2**0 CONTENTS, READONLY

Notice the Algn=2**0.

Solution: specify alignment:

.section .multiboot_header
.balign 4
header_start:

This should be done for the nasm version too, it's just accidental that it works there due to file layout.

相关问答

更多
  • BSP 是 Board support package, 板极支持包,是介于主板硬件和操作系统之间的一层,应该说是属于操作系统的一部分,主要目的是为了支持操作系统,使之能够更好的运行于硬件主板。BSP是相对于操作系统而言的,不同的操作系统对应于不同定义形式的BSP,例如VxWorks的BSP和Linux的BSP相对于某一CPU来说尽管实现的功能一样,可是写法和接口定义是完全不同的,所以写BSP一定要按照该系统BSP的定义形式来写(BSP的编程过程大多数是在某一个成型的BSP模板上进行修改)。这样才能与上层O ...
  • localhost-startStop-1试图创建一个SecureRandom的新实例,它试图从熵源读取数据。 这通常发生是因为来源已经枯竭。 默认的熵源是/dev/random 。 它被称为阻止源,因为当尝试读取随机数据时它会阻塞,而没有可用的数据。 Linux上的另一个来源是/dev/urandom 。 它的主要优点在于/dev/random ,它是非阻塞的。 关于使用/dev/urandom是否会降低安全性存在争议。 这篇文章可能是有趣的。 总之,使用/dev/urandom可以避免您看到的问题,但可 ...
  • 您想以非特权用户身份访问特权端口吗? 你试过在unix上以root身份运行吗? you want to access an privileged port as an unprivileged user? have you tried running this as root on unix?
  • 你的第一个例子 $ sudo qemu-system-x86_64 image.bin 使用image.bin作为“第一”磁盘。 你的第二个例子 $ sudo qemu-system-x86_64 -hdb / dev / sdb 使用“image.bin”的副本作为“第二”磁盘。 你可以试试没有“-hdb”或明确的“-hda”。 Your first example $ sudo qemu-system-x86_64 image.bin uses image.bin as "first" disk. Yo ...
  • 您可以在真实硬件上找到此代码的许多问题: 当您进入引导加载程序时,大多数寄存器的状态是未定义的 - 但是当您调用中断例程时,寄存器需要有效。 确保在启动引导扇区时立即设置段寄存器。 例如,如果ES!= CS,你跳到第二阶段将落在错误的地方。 在调用中断例程之前,确保您有一个有效的堆栈。 不要依赖可用的中断例程。 许多硬件供应商认识到构建他们的硬件适用于Windows和Linux(因为这是他们99.999%的客户想要的),并且不打算实现他们知道Windows和Linux不会调用的中断例程。 在进行磁盘访问之前 ...
  • 要查看DHCP进程是否存在问题所在,要尝试的一项测试是在DHCP服务器上运行Wireshark,以查看服务器是否收到了数据包,以及服务器是否将数据包发送回i217适配器。 如果数据包到达DHCP服务器但没有被发回,可能是防火墙问题。 我还会检查IP地址租约并确保一切看起来没有错误(即没有重复的IP,坏地址)。 此外,如果您想验证i217适配器没有已知的PXE问题,或者有任何怪癖,您可以向communities.intel.com上的有线以太网博客询问您所看到的问题。 他们通常有一些人可以在那里帮助英特尔。 ...
  • 最好和最广泛使用的方法是将您的应用程序拆分为永不更新的稳定引导加载程序,以及您可以不时更换的应用程序。 AFAIK,在Z80中只有中断向量,并且不支持在CPU本身中替换它们。 您需要在硬件中放置一些可以替换内存块的东西。 此外,您需要具备以下功能:在下载过程中,引导加载程序未在应用程序部分中使用任何内容,并阻止可以在应用程序中调用任何内容的任何中断。 The best and most widely used approach is to split your app into a stable boot ...
  • 多引导规范说: Multiboot标头必须完全包含在OS映像的前8192字节内,并且必须是长字(32位)对齐。 objdump给了我们: Idx Name Size File off Algn 3 .multiboot_header 00000018 00000040 2**0 CONTENTS, READONLY 注意Algn=2**0 。 解决方案:指定对齐: .section .multiboot_header .balign 4 header_star ...
  • 问题似乎是这个指令序列: 0x66, 0xbb, 0x0f, 0x00, // mov bx, 0FH 0xcd, 0x10, // int 10H 实模式下的操作数前缀0x66将指令解码为32位寄存器(在本例中),然后将使用4个字节对立即值进行编码。 这当然会使用int 10h作为mov的数据的一部分。 所以你的教学真正做的是: 0x66, 0xbb, 0x0f, 0x00, 0xcd, 0x10, // mov ebx,0x10cd000f 然后会出现hlt ...
  • 一旦引导加载程序完成初始化任务,它就会将系统的控制权转移到操作程序/系统。 具体指令通常是跳转或分支,具体取决于特定的引导加载程序或体系结构。 由于您特别提到了操作系统,我将参考Embedded Linux Primer : 请注意, bootm命令是U-Boot的丧钟。 这是一个重要的概念。 与桌面PC中的BIOS不同,大多数嵌入式系统的架构都是这样的,即当Linux内核获得控制权时,引导加载程序就不再存在。 内核声明了引导加载程序以前使用的所有内存和系统资源。 将控制权传递回引导加载程序的唯一方法是重新 ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)