I have the string: "1,123.456,567,567\n1,412.432.342.234\n1,314,3245,435,456\n2,324,435,246,324" So that data corresponds to this: The first part (before the comma) is the daemon ID. We can have lots of these, so relying on it just being 1 character isn't safe. We have more. So you first have the daemon ID, followed by a comma and then the IP address. After the IP address you just have another one on a new line. A database dump of this information: '1,188.8.131.52\n1,184.108.40.206' This is stored a string (yeah... I know...) So what I want to do is start the string AFTER the first comma and end it BEFORE the \ in "\n" After doing this I want to remove the entire part (so the daemon ID, the IP and the \n) from the table of available IPs and move it into a table of not available IPs, so as well as just the IP I also need to get the entire line. What I'm thinking is using a string manipulation function to get the entire line first (the first IP which starts with the daemon ID, daemon ID is in $daemonId). Then getting just the IP from that. Then running an update statement with the new text with the IP line removed from it.