Skip to content
Advertisement

Delete specific characters in text-file php

I have a text like that :

JavaScript

I want to delete the , in front of frank or eclipse, it can be any word.

My idea is to check if with have a comma before Eclipse:, or accueil: and if with have one then we delete only the comma to have :

JavaScript

But how can we delete just one commat if she exist ?

I creat the line with :

JavaScript

Advertisement

Answer

JavaScript

The regular expression matches everything from the : to the ,. The parenthesized group matches the part of that before the comma. So we replace it with $ so that we keep everything except the comma.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement